Date: Fri, 22 May 1998 02:09:47 -0400 (EDT) From: HighWind Software Information <info@highwind.com> To: freebsd-hackers@FreeBSD.ORG Cc: support@highwind.com Subject: FreeBSD 2.2.6 + pthread == write() bug Message-ID: <199805220609.CAA05884@highwind.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805220609.CAA05884>