fix(utility): don't cap ReadAvailable's first read at the drain timeout#754
Open
codyprime wants to merge 1 commit into
Open
fix(utility): don't cap ReadAvailable's first read at the drain timeout#754codyprime wants to merge 1 commit into
codyprime wants to merge 1 commit into
Conversation
ReadAvailable wraps around ReadAvailableWithOptions, using pre-defined default values for convenience. The default readTimeout is only 10ms. After 9572dd0, the readTimeout is applied to the first read on the conn, not just subsequent reads. This means very short read values (default is 10ms) will fail most of the time, for non-local connections. This impacts dnp3, fox, rdp; their first read had an effective timeout of 10ms. It probably also impacts modules that use ReadAvailableWithOptions, if they specify relatively short timeouts (memcached, jarm, telnet all specified 500ms) Bound the first read by totalTimeout instead (falling back to the conn's session timeout); readTimeout now applies only to the drain reads. This has the added benefit of honoring the timeout value passed to a scanner for the first read, if the scanner passes 0 in for the total timeout. If no total timeout is provided, rather than defaulting to 1s, it now defaults to DefaultSessionTimeout (becoming the only user of DefaultSessionTimeout I believe). This seems appropriate, given the description for it: "the default maximum time a connection may be used when no explicit value is provided"
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.
ReadAvailable wraps around ReadAvailableWithOptions, using pre-defined default values for convenience. The default readTimeout is only 10ms.
After 9572dd0, the readTimeout is applied to the first read on the conn, not just subsequent reads. This means very short read values (default is 10ms) will fail most of the time, for non-local connections. This impacts dnp3, fox, rdp; their first read had an effective timeout of 10ms. I expect the success rate for these protocols on main is roughly 0%.
It probably also impacts modules that use ReadAvailableWithOptions, if they specify relatively short timeouts (memcached, jarm, telnet all specify 500ms)
Bound the first read by totalTimeout instead (falling back to the conn's session timeout); readTimeout now applies only to the drain reads. This has the added benefit of honoring the timeout value passed to a scanner for the first read, if the scanner passes 0 in for the total timeout.
If no total timeout is provided, rather than defaulting to 1s, it now defaults to DefaultSessionTimeout (becoming the only user of DefaultSessionTimeout I believe). This seems appropriate, given the description for it: "the default maximum time a connection may be used when no explicit value is provided"
How to Test
Pick a DNP3 server that is not local. (I won't provide an example one here, since this is a SCADA service).
Pre-fix:
Post-fix: