Merge "Add synchronized block when accessing global variables" into main am: 8f6df28f50

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2770830

Change-Id: I0514c4a1b79d7cd9536f975eb0bcf119f4103bb1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Junyu Lai
2023-10-20 06:20:44 +00:00
committed by Automerger Merge Worker

View File

@@ -517,11 +517,12 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
break; break;
} }
case MSG_NOTIFY_NETWORK_STATUS: { case MSG_NOTIFY_NETWORK_STATUS: {
synchronized (mStatsLock) {
// If no cached states, ignore. // If no cached states, ignore.
if (mLastNetworkStateSnapshots == null) break; if (mLastNetworkStateSnapshots == null) break;
// TODO (b/181642673): Protect mDefaultNetworks from concurrent accessing.
handleNotifyNetworkStatus( handleNotifyNetworkStatus(
mDefaultNetworks, mLastNetworkStateSnapshots, mActiveIface); mDefaultNetworks, mLastNetworkStateSnapshots, mActiveIface);
}
break; break;
} }
case MSG_PERFORM_POLL_REGISTER_ALERT: { case MSG_PERFORM_POLL_REGISTER_ALERT: {