summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-02-03 00:16:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-02-03 00:16:26 +0000
commit5d559ac7008e8ee574420f9ac42a4428dbda0e0e (patch)
tree420ba638a36379ddff6b1e800594c009bfa99a62
parent519201b871491b4b8e47aff71a2eded44d2cc207 (diff)
parentc7f94ac6347aaa77f890d1b382177968d2581894 (diff)
downloadbase-5d559ac7008e8ee574420f9ac42a4428dbda0e0e.tar.gz
Merge "Fix thread safety issue on clearing cache" into rvc-dev
-rw-r--r--cmds/statsd/src/external/StatsPullerManager.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index 8a9ec7456e55..99c39f6017b1 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -334,6 +334,7 @@ void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {
}
int StatsPullerManager::ForceClearPullerCache() {
+ std::lock_guard<std::mutex> _l(mLock);
int totalCleared = 0;
for (const auto& pulledAtom : kAllPullAtomInfo) {
totalCleared += pulledAtom.second->ForceClearCache();
@@ -342,6 +343,7 @@ int StatsPullerManager::ForceClearPullerCache() {
}
int StatsPullerManager::ClearPullerCacheIfNecessary(int64_t timestampNs) {
+ std::lock_guard<std::mutex> _l(mLock);
int totalCleared = 0;
for (const auto& pulledAtom : kAllPullAtomInfo) {
totalCleared += pulledAtom.second->ClearCacheIfNecessary(timestampNs);