Apply the request deadline to TCP frame reads - #137
Merged
Conversation
Requester#request computes a monotonic time limit but only the socket readability wait honoured it, so a peer that sends an incomplete frame and keeps the connection open blocked past the configured timeouts until it closed. The parameter defaults to nil, which keeps the previous blocking behaviour for anyone calling recv_reply the old way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Giving up part way through a frame leaves the stream between frame boundaries, so reusing the cached requester made every later attempt read the previous frame's bytes as a length prefix. Asking the requester instead of its class keeps a connection whose stream is still on a boundary, which a plain timeout has no reason to throw away. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
hsbt
force-pushed
the
tcp-frame-read-deadline
branch
from
August 24, 2026 23:01
37f383f to
791447b
Compare
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.
Resolv::DNS::Requester#requestcomputes a monotonic time limit from the configured timeouts, but only the socket readability wait honours it. Once the socket becomes readable,Requester::TCP#recv_replycalls blockingreadtwice, so a peer that sends an incomplete length prefix or message body and keeps the connection open blocks the call until the peer closes the connection.This passes the time limit down to
recv_replyand makes the TCP reader complete each frame within it, raisingResolvTimeouton expiry just like the readability wait does. The UDP requesters are unchanged since a readable socket yields a complete datagram in one call. The parameter defaults tonil, which keeps the previous blocking behaviour and existing subclass signatures working. TheEOFErrorbehaviour for early connection close from #105 is preserved.