Skip to content

Apply the request deadline to TCP frame reads - #137

Merged
hsbt merged 2 commits into
masterfrom
tcp-frame-read-deadline
Aug 24, 2026
Merged

Apply the request deadline to TCP frame reads#137
hsbt merged 2 commits into
masterfrom
tcp-frame-read-deadline

Conversation

@hsbt

@hsbt hsbt commented Aug 5, 2026

Copy link
Copy Markdown
Member

Resolv::DNS::Requester#request computes a monotonic time limit from the configured timeouts, but only the socket readability wait honours it. Once the socket becomes readable, Requester::TCP#recv_reply calls blocking read twice, 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_reply and makes the TCP reader complete each frame within it, raising ResolvTimeout on 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 to nil, which keeps the previous blocking behaviour and existing subclass signatures working. The EOFError behaviour for early connection close from #105 is preserved.

hsbt and others added 2 commits August 25, 2026 08:00
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
hsbt force-pushed the tcp-frame-read-deadline branch from 37f383f to 791447b Compare August 24, 2026 23:01
@hsbt
hsbt merged commit e458687 into master Aug 24, 2026
74 checks passed
@hsbt
hsbt deleted the tcp-frame-read-deadline branch August 24, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant