RFC: Too many race conditions.

Jeroen Frijters jeroen@sumatra.nl
Tue May 22 05:05:00 GMT 2007

David Daney wrote:
> The only way to close the race window using user space synchronization
> is to make the close block while you could be calling write().

That's not true. You can use ref counting to protect access to the fd and then close the fd when the ref count reaches zero. This way the actual native close can happen in any operation (read/write/close) or the finalizer, but is guaranteed only to happen when no other operation is in progress.

This is how .NET 2.0 does it. See http://blogs.msdn.com/cbrumme/archive/2004/02/20/77460.aspx for more information.


More information about the Java mailing list