diff -r 3519688a4e4d -r 07b6be5d9150 src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java --- a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java Mon Mar 18 19:59:05 2019 +0000 +++ b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java Wed Mar 20 13:54:50 2019 +0000 @@ -465,7 +465,7 @@ if (state != ChannelState.PENDING) throw new NoConnectionPendingException(); } - int n = 0; + boolean connected = false; try { try { begin(); @@ -477,26 +477,11 @@ receiverThread = NativeThread.current(); } if (!isBlocking()) { - for (;;) { - n = Net.pollConnect(fd, 0); - if ( (n == IOStatus.INTERRUPTED) - && isOpen()) - continue; - break; - } + connected = Net.pollConnect(fd, 0); } else { - for (;;) { - n = Net.pollConnect(fd, -1); - if (n == 0) { - // Loop in case of - // spurious notifications - continue; - } - if ( (n == IOStatus.INTERRUPTED) - && isOpen()) - continue; - break; - } + do { + connected = Net.pollConnect(fd, -1); + } while (!connected && isOpen()); } } } finally { @@ -504,16 +489,10 @@ receiverThread = 0; if (state == ChannelState.KILLPENDING) { kill(); - /* poll()/getsockopt() does not report - * error (throws exception, with n = 0) - * on Linux platform after dup2 and - * signal-wakeup. Force n to 0 so the - * end() can throw appropriate exception */ - n = 0; + connected = false; } } - end((n > 0) || (n == IOStatus.UNAVAILABLE)); - assert IOStatus.check(n); + end(connected); } } catch (IOException x) { /* If an exception was thrown, close the channel after @@ -523,7 +502,7 @@ throw x; } - if (n > 0) { + if (connected) { synchronized (stateLock) { state = ChannelState.CONNECTED; if (!isBound()) {