Repository navigation
Use the Windows defaults for unset keepalive time or interval - #698
Closed
forzen-dev wants to merge 1 commit into
Closed
forzen-dev wants to merge 1 commit into
forzen-dev wants to merge 1 commit into
Conversation
SIO_KEEPALIVE_VALS always sets both the keep-alive timeout and the interval. A TcpKeepalive with only one of them set wrote 0 for the other: with_time alone set a 0 ms interval, so once the connection was idle every probe went out back to back and a momentary network stall dropped it; with_interval alone set a 0 ms timeout. Use the documented Windows defaults (2 hours, 1 second) for the unset field instead.
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.
On Windows,
set_tcp_keepalivefillsSIO_KEEPALIVE_VALS, which always sets both the keep-alive timeout and the interval. A field theTcpKeepaliveleaves unset was written as 0:TcpKeepalive::new().with_time(t)set a 0 ms interval. Once the connection had been idle fort, all the probes went out back to back, so a network stall of even a second at that moment dropped the connection.TcpKeepalive::new().with_interval(i)set a 0 ms timeout.On Unix each value is its own socket option, so an unset one keeps the system default. That makes
with_timealone a reasonable thing to write, and libraries do: themysqlcrate calls onlywith_timeon Windows. We saw this in a database client. Withwith_time(10 s)on Windows 11, a MySQL connection whose server stopped answering was declared dead 10 s after its last traffic, where macOS took 25 s with the same settings.This PR uses the defaults documented for
SIO_KEEPALIVE_VALS(timeout 2 hours, interval 1 second) for whichever field is unset, and notes it in thewith_time/with_intervaldocs. A new Windows unit test checks the struct built from each combination.Tested on Windows 11 x64:
cargo test --lib keepalive(with and without--features all) andcargo test --features all --test socket keepalivepass.cargo check --target x86_64-pc-windows-msvc --features allis clean. The clippy findings on that target are the same as on master and none are in this change.