Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spurious readiness notification for Select System call

On http://linux.die.net/man/2/select, under BUGS section it is mentioned that the select system call may sometimes spuriously set the FD ready and the subsequent read call will return 0. The text describes one such example (wrong checksum) but I am assuming there would be other reasons too (otherwise they would have fixed this).

Any ideas what could the other causes for Select to return a FD ready spuriously.

and does this apply to other OS'es also. I am currently asking about Linux.

Relevant Section for the link above:

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. Thus it may be safer to use O_NONBLOCK on sockets that should not block.

like image 806
Aditya Sehgal Avatar asked May 13 '09 14:05

Aditya Sehgal


1 Answers

This is not exactly an answer, but looking over epoll, these problems seem to be solved for it.

And if I can trust this message in netdev, they at least tried to fix it in poll() and select() too (breaking other things).

Thus, this bug doesn't seem to be relevant in foreseeable future.

like image 155
hynek Avatar answered Oct 24 '22 06:10

hynek