summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pavel Zhamaitsiak <pavelz@google.com> 2016-05-03 09:18:00 -0700
committer Pavel Zhamaitsiak <pavelz@google.com> 2016-05-03 09:18:00 -0700
commite8fc84b449d0b0850b1ffacdc43b103521bd2ebd (patch)
treeb02709dfdb250f601e86f1a0ea6dce6fcccc830c
parentbeb3d2990b2b480d06f465a8df4a6509ec4e098b (diff)
Fix race condition in MetricsLoggerService
Bug: 28204408 Change-Id: I7e0577d2161f6083ae84ab29db24f23415d145be
-rw-r--r--services/core/java/com/android/server/connectivity/MetricsLoggerService.java10
1 files 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) {