Skip to content

Commit e57cae6

Browse files
committed
[MTRDevice] Defer first Thread subscription until operational advertisement seen
Avoid racing the very first SubscribeRequest against threadradiod's [WED_START] on Thread cold-start, which would otherwise produce a No-route-to-host failure and burn 3-6s of coldstart on a retry. When this is the first subscription attempt for a Thread device and we have no cached IP address, defer the subscribe until either an operational mDNS advertisement arrives or a 1-second watchdog fires. Short-circuits the gate when we already have evidence the device is reachable (cached IP, recent in-memory report, recent persisted-report hint from a prior process), and bypasses entirely on the explicit sDeviceMayBeReachableReason signal. The watchdog is stored as a cancellable dispatch_block_t so invalidate/controllerSuspended/the advertisement-driven cancel path can drop its captures immediately instead of holding them for up to a full second. NSUserDefaults writes for the cross-process recency hint are funnelled through a dedicated serial queue so an invalidate-time clear is guaranteed to observe and overwrite any in-flight write (otherwise an async setObject: could land after the clear, leaving stale state that poisoned the next test run). Tests wipe stale MTRDeviceMostRecentReportTime-* keys in tearDown for the same reason.
1 parent d32383c commit e57cae6

4 files changed

Lines changed: 3538 additions & 18 deletions

File tree

0 commit comments

Comments
 (0)