man select
BUGS
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.
But I see netcat
, socat
, wget
(but not curl
) putting FDs without O_NONBLOCK to select or poll.
I've implemented a special library to test apps for this and they are failing...
/* Inspired by seeing a hung wget
that was read
ing from a stale socket and not timing out like it should */
Should I report this as bugs or they are doing it it right?
Possible answers:
- "No, blocking FD in poll/select => bug";
- "Only AF_INET[6] sockets can misfire on select, so a bug only if a blocking network socket is in poll/select";
- "Yes, report bugs only if/when you see a real-world failure because of this" (like in wget).