mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-25 09:01:29 +02:00
SetNetworkAvailable read IsOnline before updating netState without any locking, so concurrent availability flips could interleave: a false call could observe a stale offline state, skip MarkNetworkChange, and land after a racing true call, leaving the client offline with unswept connections. The netState and recorder updates could also apply out of order, letting the listener state disagree with netState. On Android the initial availability push at service start races the ConnectivityManager callbacks, and iOS feeds the same manager from NWPathMonitor. Hold a manager mutex across the check, sweep mark, state update and recorder update so transitions apply atomically and in order.