Skip to content

Commit f65d33d

Browse files
committed
ref(android): Hold the connection cache in an immutable snapshot
The cache was four fields (capabilities, network, freshness deadline and a version counter) guarded by a lock, written in four places that each had to remember to bump the version. onAvailable wrote the network without the lock, and the status lookup read the capabilities twice, so a concurrent unregister could make it report DISCONNECTED instead of querying. Replace them with an immutable ConnectionSnapshot in an AtomicReference. Writes swap in a new snapshot with compare-and-set, a refresh stores its result only if the snapshot is unchanged, and readers derive status and type from one snapshot. The capabilities that decide a significant change are now per instance instead of a static array rewritten by every constructor. Refs #6509
1 parent 67723d7 commit f65d33d

2 files changed

Lines changed: 186 additions & 120 deletions

File tree

0 commit comments

Comments
 (0)