public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andries Brouwer <Andries.Brouwer@cwi.nl>
To: linux@horizon.com
Cc: Andries.Brouwer@cwi.nl, linux-kernel@vger.kernel.org,
	cfriesen@nortelnetworks.com
Subject: Re: [PATCH] Re: UDP recvmsg blocks after select(), 2.6 bug?
Date: Fri, 8 Oct 2004 13:45:49 +0200	[thread overview]
Message-ID: <20041008114549.GD7561@apps.cwi.nl> (raw)
In-Reply-To: <20041007124909.12995.qmail@science.horizon.com>

On Thu, Oct 07, 2004 at 12:49:09PM -0000, linux@horizon.com 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


      reply	other threads:[~2004-10-08 11:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-07 12:49 [PATCH] Re: UDP recvmsg blocks after select(), 2.6 bug? linux
2004-10-08 11:45 ` Andries Brouwer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041008114549.GD7561@apps.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=cfriesen@nortelnetworks.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox