New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip TCP_NODELAY on sockets that NIO doesn't explicitly support #2476
Skip TCP_NODELAY on sockets that NIO doesn't explicitly support #2476
Conversation
Signed-off-by: Si Beaumont <beaumont@apple.com>
Hm, these tests pass on macOS. Was a bit of a fiddle working out how we can test this. I tried playing with the SAL-backed tests but didn't get very far. Anyone got thoughts on if and how we should test this? |
@@ -2770,39 +2770,66 @@ public final class ChannelTests: XCTestCase { | |||
XCTAssertEqual(1, counter.errorCaughtCalls) | |||
} | |||
|
|||
func testTCP_NODELAYisOnByDefault() throws { | |||
func _testTCP_NODELAYis( | |||
enabledByDefault: Bool, |
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.
This kind of "narrative style" function name is discouraged in Swift APIs, and in this particular instance I think it's hard to read. I think it'd be better to rename this to _testTCP_NODELAYDefaultValue(value:
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.
Done.
Signed-off-by: Si Beaumont <beaumont@apple.com>
Signed-off-by: Si Beaumont <beaumont@apple.com>
Nice, Linux doesn't support getsockopt here either. Ok, we can make the SAL work, but we should sync up so I can help you drive it. |
Signed-off-by: Si Beaumont <beaumont@apple.com>
Yep, seems like it; this is the logs from CI:
I took a look and I don't think that SAL is going to be an option for testing this change, in its current form. This is because At this stage I'll remove the check for the skipping of this option for unix domain sockets. The feature of skipping for unix domain sockets isn't new in this PR and there wasn't a test for it already, and it's not clear how to test it. I can keep the update to the test that checks that we do automatically add |
Motivation:
NIO automatically calls
setsockopt
withTCP_NODELAY
unless the protocol family isPF_UNIX
. However, since NIO offers API that allows users to create sockets out of band (withConnectedSocket(_:)
andwithBoundSocket(_:)
), it cannot know whether the socket supports this option or not.Modifications:
This PR inverts the filter so that it is only added for
PF_INET
andPF_INET6
. Any other socket, e.g.PF_UNIX
, or any socket that NIO doesn't explicitly handle.Result:
TCP_NODELAY
is skipped for sockets that NIO doesn't know about.