Skip to content

Fix ListenerCoroutine shutdown check (use shutting_down_, drop unused running_)#61

Merged
dallison merged 1 commit intomainfrom
fix-listener-shutdown-flag
Apr 30, 2026
Merged

Fix ListenerCoroutine shutdown check (use shutting_down_, drop unused running_)#61
dallison merged 1 commit intomainfrom
fix-listener-shutdown-flag

Conversation

@dallison
Copy link
Copy Markdown
Owner

Summary

  • Server::ListenerCoroutine was checking !running_ to decide when to drain and exit, but subspace::Server::running_ is never assigned anywhere in the codebase. With running_ always false, the listener loop took the "we're shutting down" branch on every iteration and exited as soon as the scheduler had a single coroutine left, instead of waiting for an actual shutdown.
  • Switch the check to shutting_down_, which is the flag that Server::Stop() sets and that the discovery / gratuitous-advertise coroutines already use for the same purpose.
  • Remove the now-unused bool running_ = false; member of subspace::Server. (The unrelated running_ field in server/python/server.cc is on a different class and is not affected.)

Test plan

  • bazel test //server:server_test
  • bazel test //client:client_test
  • Manually run subspace_server + manual_tests/{pub,sub} and confirm the server keeps accepting new client connections instead of exiting prematurely once the first client disconnects.
  • Send SIGTERM / call Stop() and confirm the listener still drains correctly on actual shutdown.

Made with Cursor

ListenerCoroutine was guarding its drain-and-exit path with `!running_`,
but `running_` was never set anywhere in subspace::Server, so the loop
would treat the server as "shut down" on the very first iteration and
break out as soon as the scheduler reached a single coroutine.  The
intended flag is `shutting_down_`, which is set by the shutdown path
and is what the discovery and gratuitous-advertise coroutines also
check.

While here, remove the now-unused `running_` member of
subspace::Server.  (server/python/server.cc has its own unrelated
`running_` field on a different class; it's not affected.)

Made-with: Cursor
@dallison dallison merged commit ace0c15 into main Apr 30, 2026
6 checks passed
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.

1 participant