Skip to content

ws: make pong sending lazy#21911

Closed
icing wants to merge 7 commits into
curl:masterfrom
icing:ws-pong-queuing-lazy
Closed

ws: make pong sending lazy#21911
icing wants to merge 7 commits into
curl:masterfrom
icing:ws-pong-queuing-lazy

Conversation

@icing

@icing icing commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/ws.c
Comment thread tests/http/test_20_websockets.py Outdated
Comment thread tests/http/test_20_websockets.py Outdated
Comment thread tests/http/test_20_websockets.py Outdated
icing added 5 commits June 9, 2026 09:50
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.
@icing icing force-pushed the ws-pong-queuing-lazy branch from 4752b20 to 95ed6f3 Compare June 9, 2026 08:02
@bagder bagder closed this in 849317f Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants