tolerate EINTR in ServerSocketChannel.accept implementation

On POSIX systems, Avian sends a special signal to a thread to
implement Thread.getStackTrace() when called from a different thread.
If the target thread is blocked on a call to accept when this happens,
it will return -1, with errno set to EINTR.  Instead of treating this
as an error, we now just loop and call accept again.
This commit is contained in:
Joel Dice
2009-11-16 17:23:09 -07:00
parent 5b8a7ca566
commit 3862128a3a
2 changed files with 9 additions and 2 deletions

View File

@ -47,7 +47,14 @@ public class ServerSocketChannel extends SelectableChannel {
}
private int doAccept() throws IOException {
return natDoAccept(channel.socket);
while (true) {
int s = natDoAccept(channel.socket);
if (s != -1) {
return s;
}
// todo: throw ClosedByInterruptException if this thread was
// interrupted during the accept call
}
}
private int doListen(String host, int port) throws IOException {