Repository navigation
Track Go Wireless and handoff together so a second request cannot run alongside - #51
Merged
Merged
Conversation
Only handoff was tracked, and only late. Both flows now reserve the phone in a shared InFlightOperations before doing anything, release it in a finally, and reject a second Go Wireless or handoff for the same phone with a reason (IPC reply and an alreadyRunning status event). The reconnector skips a phone while either runs; auto-launch suppression stays handoff-only.
2 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #19
What
Go Wireless and handoff now share one in-flight tracker per USB serial. A second request for a phone that already has one running is turned away with a clear reason, and the reconnector leaves the phone alone while either runs.
Why
Only handoff was tracked (
handoffInFlight), and only after its model lookup. Go Wireless, which waits up to 3 minutes, was not tracked at all, and neither flow checked for another. Two flows for one phone senttcpiptwice (each restarts adbd) and raced to launch a mirror, and the reconnector could probe the same address Go Wireless was already retrying.How
InFlightOperations(small class,lib/src/in_flight_operations.dart):tryStart(serial, operation)returns null if it reserved the phone, or the name of the operation already running;finish(serial)releases it;serialsis a copy for the reconnector.bin/daemon.dart:startGoWireless/startHandoffreserve the phone as their first synchronous step (nothing awaits between the check and the reservation, so two commands arriving back to back cannot both pass) and release it in afinally. They return why a request was turned away, or null.{started: false, reason}instead of{started: true}; awirelessStatus/handoffStatusevent with the new stagealreadyRunningand the reason is broadcast so a UI can show it (the UI displays stage names as received); the daemon logs it. The stdin keys log it too. Go Wireless vs Go Wireless, handoff vs handoff, and one against the other are all rejected, for the same phone only.inFlight.serialsin both places it is used (the periodic tick and the manual retry), so it skips a phone while Go Wireless or handoff runs.messages.dart(comments only) describe the new reply shape and stage.Verified by
in_flight_operations_test.dart(7 new tests): first start, same-operation rejection, Go Wireless vs handoff in both directions, different phones independent, release and double release,serialsis a copy, and the reconnector skips a phone during Go Wireless and resumes after.started: false, reason "already in progress"), a handoff is rejected too (reason "Go Wireless is in progress"), the status eventalreadyRunningarrives, and the running flow never reports a failure; and after an operation ends (unknown serial fails at once) the same phone accepts a new request.dart analyzeclean in core, ipc, daemon. Tests: core 27, ipc 26, daemon 97 (88 onmain) pass locally on Windows. CI results are in the checks below; this is the first PR under the new branch protection.alreadyRunningstage.Risk / follow-ups
route printinside the daemon (Go Wireless looks for gateways); it is read-only, and on Ubuntu it simply finds none.finallyreleases it on any exit, but a hang inside an unbounded adb call (A stalled adb answer hangs its caller because the adb client has no read timeout #50) would hold the reservation until the call returns.alreadyRunningtext but no dialog.