diff options
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 6 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index e267ce336b..d7700acbc2 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -3880,12 +3880,16 @@ void dump_route_tables() { fclose(fp); } -// TODO: make this function thread safe if sections are generated in parallel. void Dumpstate::UpdateProgress(int32_t delta_sec) { if (progress_ == nullptr) { MYLOGE("UpdateProgress: progress_ not set\n"); 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... progress_->Inc(delta_sec); diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 0f0927cc29..75b3140b27 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -572,6 +572,8 @@ class Dumpstate { android::sp<ConsentCallback> consent_callback_; + std::recursive_mutex mutex_; + DISALLOW_COPY_AND_ASSIGN(Dumpstate); }; |