Concurrency audit, connect-lifecycle races (no fund-path call touched — connect-result gating + abort-flag
lifetime only):
- The connect task's MainCb ran onConnected() on any successful probe without re-checking that a wallet
switch / adopt / restore / shutdown had already torn the connection down — so a probe that succeeded
against the old daemon could start a refresh against one about to be stopped. Capture rpc_session_ when
posting (main thread) and, in the MainCb, drop the result (requestAbort + disconnect, not a blocking bare
disconnect) when the session changed or daemon_restarting_/shutting_down_ is set. Same guard on the
cookie-auth retry post.
- RPCClient::open() called clearAbort(), so a requestAbort() issued while a connect was still queued was
erased, stalling teardown/shutdown. open() no longer clears it; the two reconnect entry points
(tryConnect for rpc_, onConnected for fast_rpc_) clear it on the main thread first, skipped while
shutting_down_ so a shutdown abort survives. A fresh client defaults to not-aborted, so first connects
are unaffected.
HELD (not in this commit): making abortMaintenanceCalls() abort unconditionally (the UI-freeze-on-disconnect
finding) — it would also abort an in-flight user send during teardown, a send-lifecycle behaviour change
that wants explicit sign-off (it is fund-safe via the lost-reply "outcome unknown" handling, but still a
behaviour change).
Threading fix — clean build + ctest; the races are runtime-only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>