Skip to content

WebSocket and MiniUPnP shutdown still use forced thread termination

Summary

Two shutdown paths still fall back to TerminateThread after a bounded wait:

  • srchybrid/WebSocket.cpp:622
  • srchybrid/UPnPImplMiniLib.cpp:79

Both are known shutdown-only cleanup debt rather than steady-state networking logic bugs.

Current Behavior

  • WebSocket shutdown signals the listener thread and waits briefly before force-killing it if the thread does not exit in time.
  • MiniUPnP shutdown sets an abort flag, waits up to 7 seconds for the worker to exit cooperatively, and then force-kills the thread if it still appears stuck.

Risk

TerminateThread is unsafe: it does not unwind the stack, release locks, or run normal thread cleanup. In principle this can leave partially-owned state behind.

In practice, this only affects shutdown-time fallback paths, and current branch priorities do not justify the broader redesign needed to eliminate those fallbacks cleanly.

Decision

2026-04-19: Marked Wont-Fix by explicit product decision.

Rationale:

  • the issue is understood and already limited to shutdown fallback behavior
  • removing it cleanly would require wider thread-lifecycle redesign, especially for websocket accepted-worker ownership and stop coordination
  • this is not a current stability priority relative to narrower correctness work

This item should not be reopened unless shutdown-thread ownership is deliberately redesigned as part of a broader networking/shutdown cleanup pass.

Files

  • srchybrid/WebSocket.cpp:622
  • srchybrid/UPnPImplMiniLib.cpp:79