This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Too many race conditions.


On Sun, May 20, 2007 at 07:48:11PM -0700, David Daney wrote:
> It is not socket or java specific. I think of it as a defect in Posix 
> (reuse of the lowest numbered descriptor possible).

Perhaps exacerbated by POSIX. Unless handles are guaranteed to be
unique throughout the existence of a process, any reduction in re-use
would only narrow the window. It would not eliminate it. Consider the
old malloc() implementation that would purposefully not re-use
recently free()d memory. This allowed people to write code that would
continue to use memory after it had been free()d. Good, or bad? The
same would be true of allowing people to use file descriptors after
they have been closed.

In any case - I appreciated your suggested solution. The dup2() to
perform a close of the socket was clever, leaving a garbage file
descriptor in its place. Still, the overhead appears to be high as
you noted.

I find myself wishing that Java allowed for blocking socket I/O to be
truly interrupted. If Java allowed for Thread.interrupt(), the need
for close() from another thread in paralle to the accept() would be
eliminated. Alas, this would break compatibility. :-(

Cheers,
mark

-- 
mark@mielke.cc / markm@ncf.ca / markm@nortel.com     __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]