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/

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to