mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user