Repository navigation
Release all resources when a Windows named pipe socket is closed - #100
Merged
Merged
Conversation
Closing a Win32NamedPipeSocket didn't release everything it held:
- On the client side, the pipe stayed open, so the server never noticed
that the client was gone.
- Every socket leaked two Windows event handles.
- Every socket leaked a TCP socket. The base class java.net.Socket
creates one when the read timeout is looked up, which every read does,
and only Socket.close() releases it.
Now close() releases all of these, and calling it twice is harmless.
Behavior change: reading from a closed named pipe socket now throws
SocketException("Socket is closed"), as java.net.Socket does. This comes
from calling Socket.close(), which is needed to release the TCP socket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing a
Win32NamedPipeSocketdidn't release everything it held:java.net.Socketcreates one when the read timeout is looked up, which every read does, and onlySocket.close()releases it.Now
close()releases all of these, and calling it twice is harmless.Behavior change: reading from a closed named pipe socket now throws
SocketException("Socket is closed"), asjava.net.Socketdoes. This comes from callingSocket.close(), which is needed to release the TCP socket.