Don't hang in stop() while a connection is live #6

Merged
balint merged 1 commit from fix/signaling-stop-hang into main 2026-06-06 21:16:48 +01:00
Owner

Follow-up to the peer-filter work (#5), where I noticed this while testing.

Why

SignalingChannel.stop() closed the listening server and awaited wait_closed() before dropping the live connection. An adopted inbound connection is one of the server's accepted sockets, and wait_closed() blocks until every accepted socket is closed — so with a live inbound link, stop() hung forever.

It didn't bite the running app because the link is usually dropped before shutdown, but it's a latent hang on the shutdown path.

Change

  • Drop the connection first, then close and await the server.
  • Add loopback lifecycle tests (tests/test_signaling.py): shutdown with a live inbound connection, and shutdown while idle. The first hangs and times out against the old ordering — verified by temporarily reverting just the reorder.

🤖 Generated with Claude Code

Follow-up to the peer-filter work (#5), where I noticed this while testing. ## Why `SignalingChannel.stop()` closed the listening server and awaited `wait_closed()` *before* dropping the live connection. An adopted **inbound** connection is one of the server's accepted sockets, and `wait_closed()` blocks until every accepted socket is closed — so with a live inbound link, `stop()` hung forever. It didn't bite the running app because the link is usually dropped before shutdown, but it's a latent hang on the shutdown path. ## Change - Drop the connection first, then close and await the server. - Add loopback lifecycle tests (`tests/test_signaling.py`): shutdown with a live inbound connection, and shutdown while idle. The first hangs and times out against the old ordering — verified by temporarily reverting just the reorder. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
SignalingChannel.stop() closed the server and awaited wait_closed() before
dropping the connection. An adopted inbound connection is one of the server's
accepted sockets, and wait_closed() blocks until every accepted socket is
closed — so with a live inbound link stop() hung forever.

Drop the connection first, then close and await the server. Add loopback
lifecycle tests covering shutdown with a live inbound connection and while
idle; the first hangs (and times out) against the old ordering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
balint merged commit a89037daa2 into main 2026-06-06 21:16:48 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
balint/phone!6
No description provided.