Merge "Add synchronized block when accessing global variables" into main

This commit is contained in:
Junyu Lai
2023-10-20 06:06:37 +00:00
committed by Gerrit Code Review

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: {