Reap connections that never complete the hello handshake#80
Merged
Conversation
Drop any managed connection still short of a completed hello handshake after 30 s, via a single drop_connection teardown path. Releases slots held by sockets that die before the WebSocket session is established (host transport delivers no close for those) and by peers that connect and stall, so phantoms can no longer wedge the player. Fixes #75
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses host-transport “phantom” connections that never complete the WebSocket/hello handshake and previously could permanently occupy the current/pending manager slots (Issue #75). It adds a provisional-connection admission timestamp and a periodic reap in ConnectionManager::loop() to drop connections that don’t complete the hello handshake within 30 seconds, using a unified teardown helper.
Changes:
- Track per-connection “provisional/admitted” time via an atomic timestamp on
SendspinConnection. - Add a 30s provisional timeout in
ConnectionManager::loop()to dropcurrent/pendingconnections with incomplete hello handshake. - Introduce
ConnectionManager::drop_connection(...)to unify teardown logic across connection-lost, handoff, and timeout paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/connection.h | Adds atomic provisional timestamp with set/get accessors for timeout enforcement. |
| src/connection_manager.h | Defines provisional timeout constants and declares the unified drop_connection teardown helper. |
| src/connection_manager.cpp | Starts provisional timers on admission and reaps incomplete-handshake connections in loop() using drop_connection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use std::exchange for connection-slot transfers so the slots are never left moved-from (clang-analyzer-cplusplus.Move), document the conn_ptr_mutex_ requirement on on_connection_lost, and correct the drop_connection no-op wording (a stale hello-retry entry is still pruned for unmanaged connections).
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.
Drop any managed connection still short of a completed hello handshake after 30 s, via a single drop_connection teardown path. Releases slots held by sockets that die before the WebSocket session is established (host transport delivers no close for those) and by peers that connect and stall, so phantoms can no longer wedge the player.
Fixes #75