This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug libgcj/29604] Race condition in ServerSocket.accept()
- From: "ddaney at avtrex dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 26 Oct 2006 18:03:29 -0000
- Subject: [Bug libgcj/29604] Race condition in ServerSocket.accept()
- References: <bug-29604-7151@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from ddaney at avtrex dot com 2006-10-26 18:03 -------
Subject: Re: Race condition in ServerSocket.accept()
tromey at gcc dot gnu dot org wrote:
> ------- Comment #3 from tromey at gcc dot gnu dot org 2006-10-26 17:58 -------
> Instead of directly calling accept we could select or poll on the fd.
> This would let us have a timeout or an interrupt or something.
> For all I know poll would react more gracefully to another thread
> closing the fd -- but I haven't tried that.
>
The essence of the problem is that you can not temporarily drop a lock
(as Object.wait() does) in a race free manner while entering the
accept() system call. Sticking a poll before the accept may in some
cases narrow the window of the race, but it does not close it.
I was going to fix the problem in 15 Minutes, but now I think I need a
day to mull it over.
This is the type of problem that keeps us sharp...
David Daney
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29604