Skip to content

A pong waits no longer than the read's deadline - #121

Merged
sepehr-safari merged 2 commits into
mainfrom
a-pong-waits-no-longer-than-the-deadline
Sep 24, 2026
Merged

sepehr-safari merged 2 commits into
mainfrom
a-pong-waits-no-longer-than-the-deadline

Conversation

@sepehr-safari

Copy link
Copy Markdown
Contributor

Closes #118.

A ping was answered with a write that had no bound. A relay that sent pings and had stopped reading filled the socket, so the pong waited for room that never came while holding the connection's write lock. That held the read past any deadline, and any other write on the connection behind it.

With a deadline, the pong is now skipped when another write holds the lock, or when the socket has no room before the deadline. The room check is a poll for writability on IoStream that writes nothing, the same shape as the read deadline's peek. A pong frame is far below the kernel's low-water mark, so a socket that reports room takes it whole. Skipping is harmless: a peer that is not reading would not read it, and RFC 6455 lets an endpoint answer only the latest of several pings. With no deadline, a ping is answered as before.

Tests

  • with a deadline, a pong is skipped rather than waited on when the peer has no room: a stream with no room; the read returns the next message and nothing is written. Without the room check it fails.
  • with a deadline, a pong is skipped rather than queued behind another write: the write lock held by someone else; same expectation. Without the lock check the test hangs on the held lock.
  • with a deadline and room to write, a ping is still answered.

All 217 tests pass.

Release

The last commit bumps the version to 0.14.7.

A ping was answered with a write that had no bound. A relay that sent pings and had stopped reading filled the socket, and the pong waited for room that never came, holding the write lock and with it the read, past any deadline. With a deadline, the pong is skipped when another write holds the lock or when the socket has no room before the deadline, checked with a wait that writes nothing. With no deadline, a ping is answered as before.

Closes #118.
Carries the pong fix.
@sepehr-safari
sepehr-safari merged commit 5acb2bd into main Sep 24, 2026
2 checks passed
@sepehr-safari
sepehr-safari deleted the a-pong-waits-no-longer-than-the-deadline branch September 24, 2026 08:47
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.

A pong written to a relay that has stopped reading holds receiveTimeout past its deadline

1 participant