Skip to content

Commit bdb4707

Browse files
committed
add code from 8284161 along with fix of this change
1 parent d57767e commit bdb4707

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,19 @@ private void tryFinishClose() {
10191019
private void implCloseBlockingMode() throws IOException {
10201020
synchronized (stateLock) {
10211021
assert state < ST_CLOSING;
1022+
boolean connected = (state == ST_CONNECTED);
10221023
state = ST_CLOSING;
1024+
1025+
if (connected && Net.shouldShutdownWriteBeforeClose()) {
1026+
// shutdown output when linger interval not set to 0
1027+
try {
1028+
var SO_LINGER = StandardSocketOptions.SO_LINGER;
1029+
if ((int) Net.getSocketOption(fd, SO_LINGER) != 0) {
1030+
Net.shutdown(fd, Net.SHUT_WR);
1031+
}
1032+
} catch (IOException ignore) { }
1033+
}
1034+
10231035
if (!tryClose()) {
10241036
long reader = readerThread;
10251037
long writer = writerThread;

0 commit comments

Comments
 (0)