Skip to content

Fix TopicManager shutdown deadlock with connected clients - #214

Merged
jonyMarino merged 1 commit into
mainfrom
fix/topic-manager-shutdown
Sep 16, 2026
Merged

jonyMarino merged 1 commit into
mainfrom
fix/topic-manager-shutdown

Conversation

@jonyMarino

Copy link
Copy Markdown
Contributor

Problem

Closing Runtime or Unreal with a topic client still connected can hang indefinitely. TopicManager::Stop holds manager_lock_ while nng_close waits for the disconnect callback, and that callback calls UnsubscribeAll, which needs the same lock.

Change

Release the topic-data lock while joining the receiver and closing the socket. A separate lifecycle mutex serializes complete Start/Stop transitions, and repeated calls are harmless. Reacquire the data lock before resetting socket and callback state.

Add bounded subprocess regressions covering connected clients, pending receive frames, concurrent Stop calls, and repeated Start/Stop cycles. A watchdog fails the child after 10 seconds instead of hanging the test runner.

Validation

  • Windows Release suite: 374/374 passed.
  • New regressions: 20 repetitions each, all 40 passed.
  • Negative control: connected-client regression fails after 10 seconds with the original TopicManager implementation.
  • Runtime and Unreal 5.7 editor-game both reported commit 27a1825c1a0bfdf1500e0e65be51cba33e3fd2bf and exited normally with clients/publications active: Runtime 0.409 s, Unreal 1.956 s. Each completed 5 scene reloads and 3 reconnects first; Unreal also delivered valid RGB/depth. These focused shutdown checks did not repeat flight commands. No test processes/listeners remained.

@jonyMarino
jonyMarino merged commit d1e31b4 into main Sep 16, 2026
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