AstrBot-Desktop/src-tauri
YokiiroBW b2ecd1f3a4 fix(net): probe connection slots outside the runtime lock
activate_slot held the single mutex that covers both slots across
health() and probe(). Those go through the REST client, whose total
timeout is 120s, so one unreachable address froze every runtime command
on both slots for that long: status polling, sending, cancelling and
disconnecting all blocked on the same lock. The cancellation token was
also only created after a successful probe, so the activation itself
could not be interrupted.

Split the function into three phases. Validation and client
construction happen first with no lock held; a short critical section
then bumps the generation, installs the cancellation token up front and
publishes the Connecting snapshot; the probe runs outside the lock
inside a biased select against that token; and a final critical section
writes the result back only if the slot still belongs to this
activation.

The listener receives the same token that phase one installed. Creating
a second one there would leave deactivate_slot cancelling a token no
listener observes, so the desktop-v1 reconnect loop would outlive the
disconnect.

This also fixes a stuck-slot bug the queue did not name. Validation used
to run after the Connecting snapshot had been written, so a rejected
request tore down a working connection and left the slot in Connecting
forever, with no client and no last_error to explain it.

The three new tests were checked against a mutation that re-acquires
the lock across the probe; the two concurrency tests fail under it.

Refs: F-14 (audit P1-4).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:11:19 +08:00
..
capabilities fix(tauri): grant desktop-pet capability 2026-07-26 22:28:35 +08:00
icons feat(p00): add Tauri desktop spike foundation 2026-07-18 20:34:47 +08:00
src fix(net): probe connection slots outside the runtime lock 2026-07-27 00:11:19 +08:00
tests test(p00): add frontend browser rust and windows checks 2026-07-18 20:42:40 +08:00
build.rs feat(p00): add Tauri desktop spike foundation 2026-07-18 20:34:47 +08:00
Cargo.toml feat(p00): add Tauri desktop spike foundation 2026-07-18 20:34:47 +08:00
tauri.conf.json fix(tauri): allow blob images in production csp 2026-07-26 22:28:35 +08:00