Re: Linux select command issues
- From: "David Schwartz" <davids@xxxxxxxxxxxxx>
- Date: 7 Sep 2006 21:35:59 -0700
Logan Shaw wrote:
Is there any reason to assume you have to write your program with
the assumption select() is always passed valid sets of file
descriptors? I don't see why it's invalid to do your select(),
then after it returns, double-check any descriptors (by referring
to some data structure of your own) to see if they still refer to
what you thought they did. As long as you check a superset of
the descriptors you actually need, you should be OK.
If a file descriptor has been closed and re-opened and isn't what
it was before, as long as you track that and are aware of the fact,
there is no harm in having been notified of some condition on that
file descriptor. It's just superfluous information, which is
harmless if you recognize it as such.
It comes down to whether or not 'select' is a pure status reporting
function. If it's a pure status reporting function, there is no harm is
asking the status of something in which you have no interest. However,
if 'select' was more than a pure status reporting function, then
'select'ing on something that wasn't yours could cause problems.
Consider, for example, a hypothetical system on which a 'select' hit
for write actually guaranteed that a subseqent write would not block.
What would happen if you 'select'ed for write on a socket that wasn't
yours (say because the descriptor was yours recently), and then the
thread that owned that socket did a 'write' that it expected to block
but then *surprise* didn't block?
So you are correct if and only if 'select' is a pure status-reporting
function that cannot change or affect the semantics of operations after
it.
Some have argued that a 'select' hit for readability on a UDP socket
prohibits the implementation from dropping the datagram that it
reported (or else a subsequent 'read' could block). If you believe
that, then 'select' is not a pure status-reporting function. However,
this status change, AFAICT, can't harm anything. But if it can perform
status changes that are harmless, perhaps it can also perform status
changes that are harmful.
DS
.
- Follow-Ups:
- Re: Linux select command issues
- From: Logan Shaw
- Re: Linux select command issues
- References:
- Linux select command issues
- From: jeffmax
- Re: Linux select command issues
- From: joe
- Re: Linux select command issues
- From: David Schwartz
- Re: Linux select command issues
- From: Casper H . S . Dik
- Re: Linux select command issues
- From: David Schwartz
- Re: Linux select command issues
- From: Logan Shaw
- Linux select command issues
- Prev by Date: Re: max number of open fd to be used for max sim. connections
- Next by Date: Re: max number of open fd to be used for max sim. connections
- Previous by thread: Re: Linux select command issues
- Next by thread: Re: Linux select command issues
- Index(es):
Relevant Pages
|