mirror of
https://github.com/corda/corda.git
synced 2025-03-03 12:57:29 +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:
parent
5b8a7ca566
commit
3862128a3a
@ -266,7 +266,7 @@ doAccept(JNIEnv* e, int s)
|
||||
int r = ::accept(s, &address, &length);
|
||||
if (r >= 0) {
|
||||
return r;
|
||||
} else {
|
||||
} else if (errno != EINTR) {
|
||||
throwIOException(e);
|
||||
}
|
||||
return -1;
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user