Re: TCP hangs in 2.4 - blocking write() in wait_for_tcp_memory

bert hubert (ahu@ds9a.nl)
Wed, 30 Oct 2002 13:28:12 +0100


On Wed, Oct 30, 2002 at 10:44:20AM +0000, Miquel van Smoorenburg wrote:

> This makes both socket programs hang in write(), in wait_for_tcp_memory.
> Shouldn't the kernel return a short write, instead of hanging
> both processes ? select() returned writeability.

write(2) is allowed to do a short write on a blocking socket, but not
mandated to do so. In fact I've only seen short writes under
linux on non-blocking sockets.

SuSv3 says:

Blocking/immediate: Blocking is only possible with O_NONBLOCK clear. If
there is enough space for all the data requested to be written immediately,
the implementation should do so. Otherwise, the process may block; that is,
pause until enough space is available for writing. The effective size of a
pipe or FIFO (the maximum amount that can be written in one operation
without blocking) may vary dynamically, depending on the implementation, so
it is not possible to specify a fixed value for it.

...

Partial and deferred writes are only possible with O_NONBLOCK set.

Regards,

bert

-- 
http://www.PowerDNS.com          Versatile DNS Software & Services
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/