RFR: 8358764: (sc) SocketChannel.close when thread blocked in read causes connection to be reset (win)
Jaikiran Pai
jpai at openjdk.org
Tue Jun 10 13:56:30 UTC 2025
On Mon, 9 Jun 2025 19:17:16 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> On Windows, if a platform thread is blocked in SocketChannel.read, and another thread closes the channel, then Windows abruptly closes the connection (RST). In releases prior to JDK 11, the connection was shutdown for writing before closing so the connection was closed gracefully, an unexpected behavior change
>
> implCloseBlockingMode is changed to shutdown the connection for writing on Windows, no change in behavior for other platforms.
src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java line 1125:
> 1123: state = ST_CLOSING;
> 1124:
> 1125: if (connected && Net.shouldShutdownWriteBeforeClose()) {
Hello Alan, I just had a brief passing look at these changes and based on my limited knowledge of this area, they look reasonable to me. I'll take a more detailed look tomorrow. Is the use of a JNI function, to determine whether or not we should shutdown before close, done for the sake of consistency with the rest of the platform specific logic?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25700#discussion_r2137971071
More information about the nio-dev
mailing list