ws: make pong sending lazy#21911
Closed
icing wants to merge 7 commits into
Closed
Conversation
bagder
approved these changes
Jun 8, 2026
There was a problem hiding this comment.
Pull request overview
This PR adjusts curl’s WebSocket implementation to avoid sending (and buffering) PONG frames when the WebSocket send buffer is already “too full”, based on RFC 6455’s allowance for skipping intermediary PONGs. It also adds an HTTP-test that stresses the client with a server blasting many PING frames and asserts that the client’s RSS does not materially increase across runs.
Changes:
- Make control-frame (PONG) sending “lazy” by deferring enqueue/flush behavior until there is buffer space.
- Adjust WebSocket decode writer flow to flush pending control frames opportunistically.
- Add a new stress test that measures RSS under heavy PING load.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/http/test_20_websockets.py | Adds a new “crazy pings” stress test that uses profiling RSS to detect memory growth. |
| lib/ws.c | Defers control-frame sending and adds logic in ws_flush() to only enqueue pending control frames when there is space. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Do not send PONG frames unless there is sufficient space left in the websocket send buffer. A server might be lazy in reading our data and intermediary PONG frames can be skipped by a client (RFC 6455, ch. 5.5.3). Add test case measuring no real RSS increase on a server blasting with PING frames.
4752b20 to
95ed6f3
Compare
2 tasks
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.
Do not send PONG frames unless there is sufficient space left in the websocket send buffer. A server might be lazy in reading our data and intermediary PONG frames can be skipped by a client (RFC 6455, ch. 5.5.3).
Add test case measuring no real RSS increase on a server blasting with PING frames.