Fix infinite loop in post-relay flush when peer stops reading#598
Open
renaudallard wants to merge 1 commit intotinyproxy:masterfrom
Open
Fix infinite loop in post-relay flush when peer stops reading#598renaudallard wants to merge 1 commit intotinyproxy:masterfrom
renaudallard wants to merge 1 commit intotinyproxy:masterfrom
Conversation
write_buffer() returns 0 on EAGAIN/EWOULDBLOCK (from SO_SNDTIMEO timeout), but the flush loops after relay_connection() only broke on return < 0. This caused an infinite retry loop when the peer stopped accepting data: send() would block for idletimeout seconds, return EAGAIN, write_buffer would return 0, and the loop would retry forever. Each stuck thread consumes a maxclients slot. Once all slots are exhausted, the proxy stops accepting new connections entirely. Fix: break on write_buffer() <= 0 in both client and server flush loops. These are best-effort flushes after the main relay loop already delivered the bulk of the data.
Contributor
|
nice debugging work here. but imo your PR doesn't go far enough, that's why i opened #599 . would you mind testing my PR and confirming whether it fixes the issues you encountered ? |
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.
write_buffer() returns 0 on EAGAIN/EWOULDBLOCK (from SO_SNDTIMEO timeout), but the flush loops after relay_connection() only broke on return < 0. This caused an infinite retry loop when the peer stopped accepting data: send() would block for idletimeout seconds, return EAGAIN, write_buffer would return 0, and the loop would retry forever.
Each stuck thread consumes a maxclients slot. Once all slots are exhausted, the proxy stops accepting new connections entirely.
Fix: break on write_buffer() <= 0 in both client and server flush loops. These are best-effort flushes after the main relay loop already delivered the bulk of the data.