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

From: Andries Brouwer
Date: Fri Oct 08 2004 - 06:48:22 EST


On Thu, Oct 07, 2004 at 12:49:09PM -0000, linux@xxxxxxxxxxx wrote:

> How about the following?

> +.B pselect
> +is currently emulated with a user-space wrapper that has a race condition.
> +For reliable (and more portable) signal trapping, use the self-pipe trick.
> +(Where a signal handler writes to a pipe whose other end is read by the
> +main loop.)

Thanks, added.

> +.B select
> +and
> +.B pselect
> +permit blocking file descritprs in the fd_sets, even though
> +there is no valid reason for a program to do this.

Hmm.

> +When
> +.B select
> +indicates that a file descriptor is ready, this is only a strong hint,
> +not a guarantee, that a read or write is possible without blocking.

Yes, perhaps.
It was easy to decide not to take your text, since it is far too long.

Presently I have

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


Your above few lines on the self-pipe trick suffice for select.2,
but I wouldnt mind if you (or anybody else) wrote something a bit
more explicit in select_tut.2.

Andries

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/