Re: writev() BUGS!

Jens-Uwe Mager (jum@ra.han.de)
Thu, 3 Jun 1999 20:02:43 GMT


On Thu, 3 Jun 1999 12:52:51 GMT, Richard B. Johnson <root@chaos.analogic.com> wrote:
>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.

The UNIX manual pages on the X/OPEN web page does say that writev behaves
like write and in the socket case like a send. I see no reason why writev
should behave differently than a write.

-- 
Jens-Uwe Mager	<pgp-mailto:62CFDB25>

- 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/