Date: Tue, 08 Jul 2008 08:32:18 -0400 From: Sergey Babkin <babkin@verizon.net> To: Robert Watson <rwatson@FreeBSD.org> Cc: arch@FreeBSD.ORG, David Schultz <das@FreeBSD.ORG>, Poul-Henning Kamp <phk@phk.freebsd.dk> Subject: Re: Proposal: a revoke() system call Message-ID: <48735E52.65BE464B@verizon.net> References: <9484951.340521215467447990.JavaMail.root@vms126.mailsrvcs.net> <20080708001929.E63144@fledge.watson.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Robert Watson wrote: > > On Mon, 7 Jul 2008, Sergey Babkin wrote: > > > This leaves a small race window between fd is checked and read() is > > executed. If in the meantime another thread does close() (and sets > > mystructure.fd to -1), and the third thread does open() then the result of > > this open would use the same fd number as our old fd (since now it's likely > > to be the lowest available number), then read() would happen on a completely > > wrong file. And yes, it does happen in real world. The best workaround I've > > come up with is a small pause between setting mystructure.fd = -1 and > > calling close(). > > > > The point of proposal is to do a close() without freeing the file > > descriptor. > > Which can be accomplished by calling dup2(2) to replace the file descriptor > with another file descriptor, perhaps one to /dev/null. It would be worth Yes, dup2() is certainly a better idea than a separate call. I've just assumed that David is following the discussion so far :-) -SB
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48735E52.65BE464B>