Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86179509 authored by Yangster-mac's avatar Yangster-mac
Browse files

Fix deadlock for write-disk cmd.

Test: manual tested.
Change-Id: I6c1e1f10bbb3830c932b3d7b57df8d4960c13977
parent ca74e23b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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));
+2 −0
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }
}