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

Commit bf63d8a5 authored by Rhed Jao's avatar Rhed Jao
Browse files

Faster bugreports (4/n)

Makes update progress thread safe.

Bug: 136262402
Test: atest dumpstate_test
Test: atest dumpstate_smoke_test
Change-Id: I1cb593d236b86122d19a5a6c11496a449e519d03
parent 3c2fdbd8
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -3880,12 +3880,16 @@ void dump_route_tables() {
    fclose(fp);
    fclose(fp);
}
}


// TODO: make this function thread safe if sections are generated in parallel.
void Dumpstate::UpdateProgress(int32_t delta_sec) {
void Dumpstate::UpdateProgress(int32_t delta_sec) {
    if (progress_ == nullptr) {
    if (progress_ == nullptr) {
        MYLOGE("UpdateProgress: progress_ not set\n");
        MYLOGE("UpdateProgress: progress_ not set\n");
        return;
        return;
    }
    }
    // This function updates progress related members of the dumpstate and reports
    // progress percentage to the bugreport client. Since it could be called by
    // different dump tasks at the same time if the parallel run is enabled, a
    // mutex lock is necessary here to synchronize the call.
    std::lock_guard<std::recursive_mutex> lock(mutex_);


    // Always update progess so stats can be tuned...
    // Always update progess so stats can be tuned...
    progress_->Inc(delta_sec);
    progress_->Inc(delta_sec);
+2 −0
Original line number Original line Diff line number Diff line
@@ -572,6 +572,8 @@ class Dumpstate {


    android::sp<ConsentCallback> consent_callback_;
    android::sp<ConsentCallback> consent_callback_;


    std::recursive_mutex mutex_;

    DISALLOW_COPY_AND_ASSIGN(Dumpstate);
    DISALLOW_COPY_AND_ASSIGN(Dumpstate);
};
};