public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Does Linux select() violate POSIX?
@ 2011-06-18 17:06 Nemo Publius
  2011-06-18 17:43 ` Eric Dumazet
  2011-06-22 18:20 ` Chris Friesen
  0 siblings, 2 replies; 10+ messages in thread
From: Nemo Publius @ 2011-06-18 17:06 UTC (permalink / raw)
  To: linux-kernel

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?


According to the Linux select man page
(http://linux.die.net/man/2/select), the answer is yes:

"Under Linux, select() may report a socket file descriptor as "ready
for reading", while nevertheless a subsequent read blocks. This could
for example happen when data has arrived but upon examination has
wrong checksum and is discarded. There may be other circumstances in
which a file descriptor is spuriously reported as ready."


According to the POSIX specification for select
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html),
the answer is no:

"A descriptor shall be considered ready for reading when a call to an
input function with O_NONBLOCK clear would not block, whether or not
the function would transfer data successfully. (The function might
return data, an end-of-file indication, or an error other than one
indicating that it is blocked, and in each of these cases the
descriptor shall be considered ready for reading.)"


There are only three possibilities:

1) I am mis-reading the POSIX spec.
2) The Linux select() man page is wrong.
3) Linux select() violates the POSIX spec.

So, which is it?

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-22 18:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-18 17:06 Does Linux select() violate POSIX? Nemo Publius
2011-06-18 17:43 ` Eric Dumazet
2011-06-18 18:22   ` Nemo Publius
2011-06-18 18:33     ` Alan Cox
2011-06-18 18:51       ` Nemo Publius
2011-06-19 14:41         ` Bernd Petrovitsch
2011-06-19 22:21           ` Nemo Publius
2011-06-19 22:32             ` Alan Cox
2011-06-19 22:45               ` Nemo Publius
2011-06-22 18:20 ` Chris Friesen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox