All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
To: Alexander Viro <viro@math.psu.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: PROBLEM: I/O system call never returns if file desc is closed in the
Date: 07 Jun 2001 14:25:37 +0200	[thread overview]
Message-ID: <tgk82obhoe.fsf@mercury.rus.uni-stuttgart.de> (raw)
In-Reply-To: <Pine.GSO.4.21.0106070042280.11086-100000@weyl.math.psu.edu>
In-Reply-To: <Pine.GSO.4.21.0106070042280.11086-100000@weyl.math.psu.edu> (Alexander Viro's message of "Thu, 7 Jun 2001 00:43:41 -0400 (EDT)")

Alexander Viro <viro@math.psu.edu> writes:

> On 7 Jun 2001, Florian Weimer wrote:
> 
> > Matthias Urlichs <smurf@noris.de> writes:
> > 
> > > Select is defined as to return, with the appropriate bit set, if/when
> > > a nonblocking read/write on the file descriptor won't block. You'd get
> > > EBADF in this case, therefore causing the select to return would be a
> > > Good Thing.
> > 
> > How do you avoid race conditions if more than one thread is creating
> > file descriptors?  I think you can only do that under very special
> > circumstances, and it definitely requires some synchronization.
> 
> The same way as you do it for many threads doing any allocations.

There's a subtle difference: For malloc(), libc has a mutex (or
whatever), but for open(), socket() etc., no locking is performed, and
many libc functions create (and destroy) descriptors imlicitely.  

I still don't see how you can write maintainable and reliable software
with asynchronous close().  For example, if some select() call returns
EBADF after an asynchronous close(), you would have to scan the
descriptors to find the offending one, but in the meantime, it has
been reused by another thread.  What do you do in this case?

-- 
Florian Weimer 	                  Florian.Weimer@RUS.Uni-Stuttgart.DE
University of Stuttgart           http://cert.uni-stuttgart.de/
RUS-CERT                          +49-711-685-5973/fax +49-711-685-5898

  reply	other threads:[~2001-06-07 14:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-06 14:26 PROBLEM: I/O system call never returns if file desc is closed in the meantime thierry.lelegard
2001-06-06 21:35 ` PROBLEM: I/O system call never returns if file desc is closed in the Alan Cox
2001-06-07  3:25   ` Matthias Urlichs
2001-06-07  4:24     ` Florian Weimer
2001-06-07  4:43       ` Alexander Viro
2001-06-07 12:25         ` Florian Weimer [this message]
2001-06-07 15:33           ` Alexander Viro
2001-06-07  4:56     ` Alexander Viro
2001-06-07  6:06       ` Matthias Urlichs
2001-06-07  6:14         ` Alexander Viro
2001-06-07 22:14     ` David Schwartz

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=tgk82obhoe.fsf@mercury.rus.uni-stuttgart.de \
    --to=florian.weimer@rus.uni-stuttgart.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@math.psu.edu \
    /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.