From owner-freebsd-hackers@FreeBSD.ORG Tue Sep 16 17:24:08 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D66316A4B3 for ; Tue, 16 Sep 2003 17:24:08 -0700 (PDT) Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6DEBB43F75 for ; Tue, 16 Sep 2003 17:24:06 -0700 (PDT) (envelope-from dan@langille.org) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id D89193D28 for ; Tue, 16 Sep 2003 20:23:55 -0400 (EDT) From: "Dan Langille" To: hackers@freebsd.org Date: Tue, 16 Sep 2003 20:23:41 -0400 MIME-Version: 1.0 Message-ID: <3F67714D.32262.7B04653@localhost> Priority: normal X-mailer: Pegasus Mail for Windows (v4.02a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Subject: [PATCH] : libc_r/uthread/uthread_write.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Sep 2003 00:24:08 -0000 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 #include #include "pthread_private.h" +#include 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/