From owner-freebsd-hackers Thu May 21 23:10:24 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA14648 for freebsd-hackers-outgoing; Thu, 21 May 1998 23:10:24 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from highwind.com (hurricane.highwind.com [209.61.45.50]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA14621 for ; Thu, 21 May 1998 23:10:17 -0700 (PDT) (envelope-from info@highwind.com) Received: (from info@localhost) by highwind.com (8.8.6/8.8.6) id CAA05884; Fri, 22 May 1998 02:09:47 -0400 (EDT) Date: Fri, 22 May 1998 02:09:47 -0400 (EDT) Message-Id: <199805220609.CAA05884@highwind.com> From: HighWind Software Information To: freebsd-hackers@FreeBSD.ORG CC: support@highwind.com Subject: FreeBSD 2.2.6 + pthread == write() bug Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG We here at HighWind are trying to port some threaded apps to FreeBSD-stable (2.2.6). Things seem to be going well, EXCEPT, we believe we found a BUG: When using pthreads (with libc_r), sometimes BLOCKING calls to write() down a connected TCP file descriptor are returning partial writes: .... ssize_t byte_count = 0; while ((byte_count = write(fd, data, bytes_to_write)) != bytes_to_write) { if (errno != EINTR && errno != EAGAIN) { if (errno != EPIPE) { // Use the HighWind "syslog" class Syslog::syslog(LOG_ERR, "Error write() of Vector Data %d/%d (%m)", byte_count, bytes_to_write); } return false; } } .... This is syslog'ing (sometimes): May 22 01:57:57 zonda typhoond[1988]: Error write() of Vector Data 2292/4096 (Undefined error: 0) Clearly, this shows the "write()" returning with less data written then was requested. This is a write() on a descriptor marked BLOCKING. It should either return "bytes_to_write" or an error. It should NEVER return less than "bytes_to_write". Please note, the "while()" loop above is strictly to handle EINTR and EAGAIN. It should NOT have to handle partial write's since this is a blocking write! My understanding is that the libc_r makes the fd "non-blocking" and does a non-blocking write under the covers. However, that should not matter. Outside the library, that write() call should be a BLOCKING write. I suspect (I'm guessing) that libc_r either forgets to remark the fd blocking, or it simply doesn't loop on a partial write when it does its non-blocking write. I don't know. We'd be happy to provide more details. This is VERY VERY bad bug for us!! We'd appreciate any help as we have a strong desire to see our products on FreeBSD. Rob Fleischman HighWind Software rmf@highwind.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message