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

Lars Marowsky-Bree
2004-10-17T13:35:49Z

On 2004-10-16T17:28:24, David Schwartz <davids@webmaster.com> wrote:

> The kernel elects to drop the packet on the call to 'recvmsg'. This is its
> right -- it can drop a UDP packet at any time. POSIX is careful not to imply
> that 'select' guarantees future behavior because this is not possible in
> principle.

I'm sorry, but according to my reading of POSIX and the Austin spec,
this is exactly what select() returning 'ready to read' implies.

The SuV spec is actually quite detailed about the options here:

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.)

This actually forbids recvmsg() to return EAGAIN and EWOULDBLOCK as
has been suggested. EIO seems to be the best fit.

But I'd have to agree that blocking on recvmsg() after select() has
indicated ready to read does violate the specification, unless the
socket has actually been opened with O_NONBLOCK.

Sincerely,
Lars Marowsky-Brée <lmb@suse.de>

--
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX AG - A Novell company