Skip to content

Apply the request deadline to TCP frame reads - #137

Open
hsbt wants to merge 1 commit into
masterfrom
tcp-frame-read-deadline
Open

Apply the request deadline to TCP frame reads#137
hsbt wants to merge 1 commit 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.

Requester#request computes a monotonic time limit but only the socket
readability wait honoured it, so a peer that sends an incomplete length
prefix or message body and keeps the connection open blocked past the
configured timeouts. The TCP reader now takes that time limit and raises
ResolvTimeout, matching what the readability wait already does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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