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
net: set tcp keepalive delay only if > 0 #3488
base: v1.x
Are you sure you want to change the base?
Conversation
If tcpkeepalive delay is zero, don't set the TCP_KEEPALIVE sock option. This will result in a) using the windows system settings or b) if previously set, no change.
for issue #3487 |
Can you add a simple test (showing that it returns successfully) and change the unix code to match? The discussion in #3487 is ongoing still, but that would push this towards a state where it can be reviewed in tandem. |
Sure, it'll take a day or so |
Ensure that uv_tcp_keepalive will accept a delay value of 0 ( meaning use previous set value, or system default, if not previously set )
added additional tests to existing file. |
docs/src/tcp.rst
Outdated
ignored when `enable` is zero. | ||
ignored when `enable` is zero. | ||
A `delay` of 0 will imply using the system default setting for tcp keepalives, |
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.
A `delay` of 0 will imply using the system default setting for tcp keepalives, | |
A `delay` of 0 will imply using the system default setting for TCP keepalives, |
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.
fixed
I think we need this logic for (at least) Linux too: https://github.com/torvalds/linux/blob/f1baf68e1383f6ed93eb9cff2866d46562607a43/net/ipv4/tcp.c#L3313 If you call I'd suggest we also apply the delay only if it's > 0 for Unix: Line 383 in 83efa3d
Last, the current flags test is insufficient. Because it's applied over an unbound socket, the delay is ignored: Line 445 in 83efa3d
@bnoordhuis WDYT? |
test: call bind to get valid socket for tests
Added requested changes. |
Looking good! Do we know what other platforms do when trying to set the delay to 0? We now know Windows resets it and Linux errors out. |
I don't have access to any other platforms, so I'm not sure how to answer. I thought I saw an issue with keepalives on an IBM OS during my original search, but I can't seems to find it now. Sorry I can't be of more help. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
I'll try to look at what the FreeBSD kernel does shortly. |
If tcpkeepalive delay is zero, don't set the TCP_KEEPALIVE sock option.
This will result in a) using the windows system settings or b) if
previously set, no change.