Date: Tue, 16 Sep 2003 20:23:41 -0400 From: "Dan Langille" <dan@langille.org> To: hackers@freebsd.org Subject: [PATCH] : libc_r/uthread/uthread_write.c Message-ID: <3F67714D.32262.7B04653@localhost> Resent-Message-ID: <Pine.BSF.4.21.0309161740160.52605@InterJet.elischer.org>
next in thread | raw e-mail | index | archive | help
I've had preliminary success with this patch. More testing needs to be done, but in the meantime, I would appreciate reviews and comments. The patched code is available from http://beta.freebsddiary.org/tmp/uthread_write.c and the patch appears below. In short, the logic has been changed to ensure that if __sys_write returns zero, this value is returned by _write. The syslog calls are just for debugging and will be removed. Thank you. --- uthread_write.c.org Tue Sep 16 12:14:22 2003 +++ uthread_write.c Tue Sep 16 16:38:02 2003 @@ -39,6 +39,7 @@ #include <unistd.h> #include <pthread.h> #include "pthread_private.h" +#include <syslog.h> ssize_t _write(int fd, const void *buf, size_t nbytes) @@ -93,7 +94,7 @@ * write: */ if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && num < nbytes))) { + errno == EAGAIN)) || (n > 0 && num < nbytes))) { curthread->data.fd.fd = fd; _thread_kern_set_timeout(NULL); @@ -136,6 +137,15 @@ ret = num; else ret = n; + + } else if (n == 0) { + ret = 0; + if (n == 0) { + setlogmask (LOG_UPTO (LOG_NOTICE)); + openlog("uthread_write.c", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); + syslog (LOG_NOTICE, "zero has been returned in uthread_write.c; num = '%d'", num); + } + break; /* Check if the write has completed: */ } else if (num >= nbytes) -- Dan Langille : http://www.langille.org/ _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F67714D.32262.7B04653>