Re: UDP recvmsg blocks after select(), 2.6 bug?

Paul Jakma
2004-10-07T13:00:47Z

On Thu, 7 Oct 2004, Martijn Sipkema wrote:

> That there is time between the select() and recvmsg() calls is not
> the issue; the data is only checked in the call to recvmsg().
> Actually the longer the time between select() and recvmsg(), the
> larger the probability that valid data has been received.

But it is the issue.

Much can change between the select() and recvmsg - things outside of
kernel control too, and it's long been known.

> But the standard clearly says otherwise.

Standards can have bugs too.

It's not healthy to take a corner-case situation from the standard on
select() and apply it globally to all IO. (not in my mind anyway,
whatever the standard says).

> Perhaps select()'s perception of state should be made to take possible
> corruption into account.

You'll /still/ run into problems, on other platforms too. Set socket
to O_NONBLOCK and deal with it ;)

> Why would the POSIX standard say recvmsg() should not block if
> it did not intend it to be used in that way?

POSIX_ME_HARDER? ;)

> Wrong. IMHO it is not exactly a good thing to not be compliant on
> such basic functionality.

Like I said, to my mind, any sane app should try avoiding assumption
that kernel state remains same between select() and read/write - and
O_NONBLOCK exists to deal nicely with the situation.

You really shouldnt assume select state is guaranteed not to change
by time you get round to doing IO. It's not safe, and not just on
Linux - whatever POSIX says.

> --ms

regards,
--
Paul Jakma paul@clubi.ie paul@jakma.org Key ID: 64A2FF6A
Fortune:
"An ounce of prevention is worth a pound of purge."