Messages in this thread | | | Date | Thu, 3 Jun 1999 08:40:42 -0400 (EDT) | From | "Richard B. Johnson" <> | Subject | Re: writev() BUGS! |
| |
On Wed, 2 Jun 1999, Jens-Uwe Mager wrote:
> On Wed, 2 Jun 1999 13:17:37 GMT, David S. Miller <davem@redhat.com> wrote: > > Date: Sat, 22 May 1999 08:17:24 -0400 (EDT) > > From: HighWind Software Information <info@highwind.com> > > > > In any case, ::writev() does sometimes perform a partial write > > on a blocking socket, that is a BUG. > > > >No, it is by no means a bug, it is perfectly fine behavior, and your > >application must check for and deal with this case. > > > >It is not getting fixed, because there is nothing to fix. > > Uhm, are you sure? I have never seen that behaviour on any > other Unix. If a socket is in blocking mode, writev (or send) > is supposed to sleep until all is send or an error occurs. I > would believe a lot software would break if write returned partial > results on blocking software. [SNIPPED]
With send(), on a BLOCKING socket, the socket should block until the data can be sent. If the length of the data is too great to send "atomically", send returns -1 with errno set to EMSGSIZE. This seems to mean that no partial messages are possible with a blocking send().
If Linux allows partial transmissions, it it not BSD socket behavior. However, it seems to be a good idea (if it didn't break existing code).
The original report was about writev(), which should write multiple buffers. Implicit is that it will take a big buffer and chop it up to lengths that can be handled by send(). writev() returns the number of bytes written or -1 with errno set. I can't find any information anywhere if it is supposed to return less than the requested bytes. However, when writting to a nearly full disk, where there are only N bytes available, the first write returns N which is less than the requested amount, subsequent writes return 0 which doesn't seem to be correct. I would expect it to return -1 with errno set to something that would allow a program to know that the disk is full (like ENOSPC).
This is probably a libc issue, though.
Cheers, Dick Johnson ***** FILE SYSTEM WAS MODIFIED ***** Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips). Warning : It's hard to remain at the trailing edge of technology.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |