-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Close Channel when input & output are closed #2450
Merged
Lukasa
merged 4 commits into
apple:main
from
felixschlegel:fs-align-closing-on-darwin-with-linux
Jun 29, 2023
Merged
Close Channel when input & output are closed #2450
Lukasa
merged 4 commits into
apple:main
from
felixschlegel:fs-align-closing-on-darwin-with-linux
Jun 29, 2023
Conversation
This file contains 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
Motivation: Suppose we have a channel whose input and output are closed. On Linux, this currently results in a full socket closure (which means TCP `RST` is being sent). This behaviour is currently different on Darwin because we don't close our socket here when our input and output are closed. We should not have two different platform-dependent behaviours here. As we cannot suppress the TCP `RST` on Linux, we have to align the Darwin behaviour to the Linux behaviour meaning we close our entire NIO channel when both the input and the output are closed. Modifications: * `BaseStreamSocketChannel`: escalate to full closure when both its input and its output are closed * add new test `ChannelTests.testInputAndOutputClosedResultsInFullClosure()` verifying the desired behaviour Result: `BaseStreamSocketChannel` will now close entirely when both input and output are closed.
67c90d3
to
892daec
Compare
felixschlegel
added a commit
to felixschlegel/swift-nio-ssl
that referenced
this pull request
Jun 23, 2023
Modifications: * `NIOSSLIntegrationTest.testCloseModeOutputServerAndClient`: remove `clientChannel.close` statement, as closing input and output of a channel results in full closure per `swift-nio` patch [#2450](apple/swift-nio#2450)
felixschlegel
added a commit
to felixschlegel/swift-nio-ssl
that referenced
this pull request
Jun 23, 2023
Modifications: * `NIOSSLIntegrationTest.testCloseModeOutputServerAndClient`: remove `clientChannel.close` statement, as closing input and output of a channel results in full closure per `swift-nio` patch [#2450](apple/swift-nio#2450)
Lukasa
requested changes
Jun 26, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extend the test to confirm that the server shuts down too?
Modifications: * `testInputAndOutputClosedResultsInFullClosure`: * prefix all server related variables with `server*` * assert that `serverConnectionChildChannel` becomes inactive once the `clientConnectionChannel` is fully closed
Lukasa
approved these changes
Jun 29, 2023
# for free
to join this conversation on GitHub.
Already have an account?
# 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.
Motivation:
Suppose we have a channel whose input and output are closed.
On Linux, this currently results in a full socket closure (which means
TCP
RST
is being sent). This behaviour is currently differenton Darwin because we don't close our socket here when our input and output are
closed.
We should not have two different platform-dependent behaviours here.
As we cannot suppress the TCP
RST
on Linux, we have to align theDarwin behaviour to the Linux behaviour meaning we close
our entire NIO channel when both the input and the output are closed.
Modifications:
BaseStreamSocketChannel
: escalate to full closure when both itsinput and its output are closed
ChannelTests.testInputAndOutputClosedResultsInFullClosure()
verifying the desired behaviour
Result:
BaseStreamSocketChannel
will now close entirely when both input andoutput are closed.