Fix socket accept loop not restarted after Sparkle update relaunch

After a Sparkle auto-update relaunches cmux, the control socket stops
accepting connections because start() early-returns when isRunning is
true, without checking if the accept loop thread is actually alive.

- Add acceptLoopAlive flag to track accept loop thread liveness
- Fix start() early-return to also check acceptLoopAlive, so a dead
  thread triggers full socket re-creation
- Break acceptLoop() after 50 consecutive accept() failures with 10ms
  backoff instead of tight-spinning forever
- Clean up socket in applicationWillTerminate and
  updaterWillRelaunchApplication for clean teardown before relaunch
This commit is contained in:
Lawrence Chen 2026-02-17 21:50:21 -08:00
parent 50fce9476c
commit 9af7df0dac
3 changed files with 21 additions and 3 deletions

View file

@ -87,6 +87,7 @@ extension UpdateDriver: SPUUpdaterDelegate {
}
func updaterWillRelaunchApplication(_ updater: SPUUpdater) {
TerminalController.shared.stop()
NSApp.invalidateRestorableState()
for window in NSApp.windows {
window.invalidateRestorableState()