From owner-freebsd-threads@FreeBSD.ORG Tue Sep 16 17:46:52 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CD0C16A4B3 for ; Tue, 16 Sep 2003 17:46:52 -0700 (PDT) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 36B5E43FBF for ; Tue, 16 Sep 2003 17:46:50 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([12.233.125.100]) by attbi.com (rwcrmhc11) with ESMTP id <20030917004029013003a5rhe>; Wed, 17 Sep 2003 00:40:29 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id RAA57270 for ; Tue, 16 Sep 2003 17:40:27 -0700 (PDT) X-Received: from mx2.freebsd.org (mx2.freebsd.org [216.136.204.119]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id RAA57155 for ; Tue, 16 Sep 2003 17:26:26 -0700 (PDT) X-Received: from hub.freebsd.org (hub.freebsd.org [216.136.204.18]) by mx2.freebsd.org (Postfix) with ESMTP id DA105571B9 for ; Tue, 16 Sep 2003 17:25:38 -0700 (PDT) (envelope-from owner-freebsd-hackers@freebsd.org) X-Received: by hub.freebsd.org (Postfix) id F04F716A4DC; Tue, 16 Sep 2003 17:25:37 -0700 (PDT) Delivered-To: julian@freebsd.org X-Received: from hub.freebsd.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id E24B216A4D9; Tue, 16 Sep 2003 17:25:37 -0700 (PDT) Delivered-To: freebsd-hackers@freebsd.org X-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) X-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) X-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 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Sender: owner-freebsd-hackers@freebsd.org Errors-To: owner-freebsd-hackers@freebsd.org ReSent-Date: Tue, 16 Sep 2003 17:40:17 -0700 (PDT) Resent-From: Julian Elischer Resent-To: threads@freebsd.org ReSent-Subject: [PATCH] : libc_r/uthread/uthread_write.c ReSent-Message-ID: Subject: [PATCH] : libc_r/uthread/uthread_write.c X-BeenThere: freebsd-threads@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Sep 2003 00:46:52 -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/ _______________________________________________ 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"