Process call events one at a time #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/serialize-call-events"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while auditing for async cleanup races (follow-up to #7). This one isn't a cleanup race but a check-then-act re-entrancy that can misbehave at runtime.
Why
Events reach
CallController.handlefrom independent sources: the button is dispatched as a fire-and-forget task (asyncio.ensure_futureinPhoneApp._on_button), while incoming messages are handled on the signaling recv loop.handle()reads the current state,awaits an action, then transitions — so two overlapping events each act on the same pre-action state:CALLINGand each sendCANCEL;ANSWERcan double-act or land in the wrong state.Change
handle()with anasyncio.Lockso each event's read → act → transition is atomic; the next event then sees the updated state. No action re-entershandle(), so there's no risk of self-deadlock.CALLING: it sendsCANCELtwice without the lock and exactly once with it.🤖 Generated with Claude Code