Files
freemo 17e7507a4d fix(lsp): release lock before blocking I/O in LspLifecycleManager.restart_server() to prevent deadlock
Refactored restart_server() to use the same 3-phase lock pattern already
employed by start_server(), eliminating a deadlock hazard that occurred when
the method held _lock across blocking I/O operations (transport.stop(),
transport.start(), and client.initialize()).

Phase 1 (short lock): reads current state, snapshots required fields, and
removes the old server entry so concurrent callers see the server as absent
during the restart window.

Phase 2 (no lock): stops the old transport, spawns the new process, and
performs the LSP handshake — all without holding _lock. These operations
can block for up to 60 seconds; holding the lock here would starve any
concurrent health_check(), list_running(), or stop_server() calls.

Phase 3 (short lock): commits the new _ManagedServer into shared state,
preserving the original ref_count.

Three new BDD scenarios added to features/lsp_lifecycle_coverage.feature:
- health_check is not blocked while restart_server is in progress
  (uses a threading.Barrier to synchronise the two threads at the exact
  moment the lock is released)
- restart_server does not hold the lock during client.initialize
  (inspects lock state from within the mock initialize() side-effect)
- restart_server preserves the ref_count of the managed server

ISSUES CLOSED: #3026
2026-04-05 07:06:53 +00:00
..
2026-02-23 03:11:12 +00:00