From e8fc84b449d0b0850b1ffacdc43b103521bd2ebd Mon Sep 17 00:00:00 2001 From: Pavel Zhamaitsiak Date: Tue, 3 May 2016 09:18:00 -0700 Subject: Fix race condition in MetricsLoggerService Bug: 28204408 Change-Id: I7e0577d2161f6083ae84ab29db24f23415d145be --- .../com/android/server/connectivity/MetricsLoggerService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/MetricsLoggerService.java b/services/core/java/com/android/server/connectivity/MetricsLoggerService.java index 6d1c5311fa8e..69ef30fbe66a 100644 --- a/services/core/java/com/android/server/connectivity/MetricsLoggerService.java +++ b/services/core/java/com/android/server/connectivity/MetricsLoggerService.java @@ -106,11 +106,13 @@ public class MetricsLoggerService extends SystemService { } private void resetThrottlingCounters(long currentTimeMillis) { - for (int i = 0; i < mThrottlingCounters.length; i++) { - mThrottlingCounters[i] = 0; + synchronized (mThrottlingCounters) { + for (int i = 0; i < mThrottlingCounters.length; i++) { + mThrottlingCounters[i] = 0; + } + mThrottlingIntervalBoundaryMillis = + currentTimeMillis + THROTTLING_TIME_INTERVAL_MILLIS; } - mThrottlingIntervalBoundaryMillis = - currentTimeMillis + THROTTLING_TIME_INTERVAL_MILLIS; } private void addEvent(ConnectivityMetricsEvent e) { -- cgit v1.2.3-59-g8ed1b