diff options
| author | 2018-01-23 15:47:15 -0800 | |
|---|---|---|
| committer | 2018-01-23 15:51:17 -0800 | |
| commit | 861795096296ebbe6d5b147519ad52a43b4b957c (patch) | |
| tree | 46e85a1a842a0a400736db8014c41637dd43bb29 | |
| parent | ca74e23b023d4a7e78ccb4f49d2e71cb9517766d (diff) | |
Fix deadlock for write-disk cmd.
Test: manual tested.
Change-Id: I6c1e1f10bbb3830c932b3d7b57df8d4960c13977
| -rw-r--r-- | cmds/statsd/src/StatsLogProcessor.cpp | 6 | ||||
| -rw-r--r-- | cmds/statsd/src/StatsLogProcessor.h | 2 | ||||
| -rw-r--r-- | cmds/statsd/src/condition/CombinationConditionTracker.cpp | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp index 9d6d8a1f2b73..666c81604a00 100644 --- a/cmds/statsd/src/StatsLogProcessor.cpp +++ b/cmds/statsd/src/StatsLogProcessor.cpp @@ -197,6 +197,10 @@ void StatsLogProcessor::onDumpReport(const ConfigKey& key, const uint64_t& dumpT void StatsLogProcessor::onDumpReport(const ConfigKey& key, vector<uint8_t>* outData) { std::lock_guard<std::mutex> lock(mMetricsMutex); + onDumpReportLocked(key, outData); +} + +void StatsLogProcessor::onDumpReportLocked(const ConfigKey& key, vector<uint8_t>* outData) { auto it = mMetricsManagers.find(key); if (it == mMetricsManagers.end()) { ALOGW("Config source %s does not exist", key.ToString().c_str()); @@ -305,7 +309,7 @@ void StatsLogProcessor::WriteDataToDisk() { for (auto& pair : mMetricsManagers) { const ConfigKey& key = pair.first; vector<uint8_t> data; - onDumpReport(key, &data); + onDumpReportLocked(key, &data); // TODO: Add a guardrail to prevent accumulation of file on disk. string file_name = StringPrintf("%s/%d-%lld-%ld", STATS_DATA_DIR, key.GetUid(), (long long)key.GetId(), time(nullptr)); diff --git a/cmds/statsd/src/StatsLogProcessor.h b/cmds/statsd/src/StatsLogProcessor.h index 301e3a535e6d..fb85aa837242 100644 --- a/cmds/statsd/src/StatsLogProcessor.h +++ b/cmds/statsd/src/StatsLogProcessor.h @@ -75,6 +75,8 @@ private: sp<AnomalyMonitor> mAnomalyMonitor; + void onDumpReportLocked(const ConfigKey& key, vector<uint8_t>* outData); + /* Check if we should send a broadcast if approaching memory limits and if we're over, we * actually delete the data. */ void flushIfNecessaryLocked(uint64_t timestampNs, const ConfigKey& key, diff --git a/cmds/statsd/src/condition/CombinationConditionTracker.cpp b/cmds/statsd/src/condition/CombinationConditionTracker.cpp index afa26f6da08a..ea6586c25d80 100644 --- a/cmds/statsd/src/condition/CombinationConditionTracker.cpp +++ b/cmds/statsd/src/condition/CombinationConditionTracker.cpp @@ -154,7 +154,7 @@ void CombinationConditionTracker::evaluateCondition( } } nonSlicedConditionCache[mIndex] = ConditionState::kUnknown; - ALOGD("CombinationPredicate %lld sliced may changed? %d", (long long)mConditionId, + VLOG("CombinationPredicate %lld sliced may changed? %d", (long long)mConditionId, conditionChangedCache[mIndex] == true); } } |