Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jul 2008 20:54:48 -0400
From:      John Baldwin <jhb@FreeBSD.org>
To:        Sergey Babkin <babkin@verizon.net>
Cc:        David Schultz <das@FreeBSD.org>, Robert Watson <rwatson@FreeBSD.org>, Poul-Henning Kamp <phk@phk.freebsd.dk>, freebsd-arch@FreeBSD.org
Subject:   Re: Proposal: a revoke() system call
Message-ID:  <200807092054.48748.jhb@freebsd.org>
In-Reply-To: <20080708164853.GA40704@zim.MIT.EDU>
References:  <9484951.340521215467447990.JavaMail.root@vms126.mailsrvcs.net> <20080708161802.N89342@fledge.watson.org> <20080708164853.GA40704@zim.MIT.EDU>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 08 July 2008 12:48:53 pm David Schultz wrote:
> On Tue, Jul 08, 2008, Robert Watson wrote:
> > These sorts of edge cases, btw, are one reason why I would *strongly* 
> > discourage application writers from doing things like calling close(2) on 
a 
> > file descriptor while still using it from another thread. :-)
> 
> My reaction is that apps should use standard concurrency control
> primitives, e.g., pthreads primitives or message queues, to
> coordinate the activities of multiple threads. The are scads of
> ways to introduce race conditions when updating various aspects of
> the process state (the fd table, in this case). Once we start
> adding special-purpose APIs to facilitate clever lock-free tricks
> in very specific cases, when will it stop? Next we'll want a
> special version of exit(), a special version of sigaction(), a
> special version of free(), and so forth.

I agree, this just sounds like an application bug.  Plus, even if we add a new 
system call that rescues drowning file descriptors it won't really help with 
writing a portable application anyway unless you get other OS's to adopt a 
similar API.

Just use the extra pipe for messages and/or real locking (in your original 
example you have an obvious race with the use of 'mystructure' and the 
solution is Don't Do That(tm)).

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807092054.48748.jhb>