Re: Does Linux select() violate POSIX?

From: Chris Friesen
Date: Wed Jun 22 2011 - 14:26:45 EST


On 06/18/2011 11:06 AM, Nemo Publius wrote:
Suppose I have a file descriptor referencing a TCP/IP socket in blocking mode.

Suppose select() reports that the descriptor is ready for reading.

If I then call recv() on that descriptor, can it _ever_ block?

There was a long discussion about this back in 2004.

http://lkml.org/lkml/2004/10/6/117

Based on that discussion and the need to deal with legacy apps, udp_poll() has special-case code to handle blocking sockets--it validates the checksum before declaring the socket readable. This costs some performance, so for non-blocking sockets the checksum validation is deferred until later when it will be hot in the cache due to the copy to userspace.

Other protocols may not handle this and so the warning is still valid in general.

Chris


--
Chris Friesen
Software Developer
GENBAND
chris.friesen@xxxxxxxxxxx
www.genband.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/