All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Ben Hamou <andre@bluetheta.com>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Multithread select() bug
Date: Tue, 11 May 2004 00:01:45 +0100	[thread overview]
Message-ID: <40A009D9.9090404@bluetheta.com> (raw)
In-Reply-To: <40A002CE.4020906@cosmosbay.com>

Eric Dumazet wrote:
> So please how do you guarantee that thread 1 runs *before* thread 2)
> 
> Thread 1)
>        select( fd)
> 
> Thread 2)
>        close(fd)
> 
> Thats not possible.
> 

I see where you're coming from, in that there is a potential race 
condition as to the socket being connected as I reach the select call.

This is an important concern but it is, I think, orthogonal to the 
original problem as there are two possible socket states at the point at 
which select gets called (as far as I can see)...

1. The socket is in its connected state
2. The socket has already been closed by the parent thread

As I understand it, if 1 is true (which corresponds to my original 
post), then select should return the moment the socket gets closed and, 
if 2 is true (which I believe corresponds to your concern), then select 
should return immediately anyway as the socket would not block if read from.

Sorry to be a pest, but I'm trying to get this clear in my head. Is it 
possible I've over-estimated the thread-safety of the select and close 
calls?

Cheers,

Andre Ben Hamou
Imperial College London

-- 

...and, on the seventh day, God switched off his Mac.

  reply	other threads:[~2004-05-10 23:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-10 21:26 Multithread select() bug Andre Ben Hamou
2004-05-10 21:47 ` Davide Libenzi
2004-05-10 21:56   ` Andre Ben Hamou
2004-05-10 22:09     ` Davide Libenzi
2004-05-10 21:57 ` Eric Dumazet
2004-05-10 22:11   ` Andre Ben Hamou
2004-05-10 22:31     ` Eric Dumazet
2004-05-10 23:01       ` Andre Ben Hamou [this message]
2004-05-11  6:07         ` Armin Schindler
2004-05-11  6:24         ` Eric Dumazet

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=40A009D9.9090404@bluetheta.com \
    --to=andre@bluetheta.com \
    --cc=dada1@cosmosbay.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.