Skip to content

Reap connections that never complete the hello handshake#80

Merged
kahrendt merged 2 commits into
mainfrom
fix/provisional-connection-timeout
Jul 9, 2026
Merged

Reap connections that never complete the hello handshake#80
kahrendt merged 2 commits into
mainfrom
fix/provisional-connection-timeout

Conversation

@kahrendt

@kahrendt kahrendt commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 drop current/pending connections 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.

Comment thread src/connection_manager.cpp
Comment thread src/connection_manager.h
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).
@kahrendt kahrendt merged commit 647b9cc into main Jul 9, 2026
5 checks passed
@kahrendt kahrendt deleted the fix/provisional-connection-timeout branch July 9, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants