diff options
| author | 2020-10-21 12:04:23 +0000 | |
|---|---|---|
| committer | 2020-10-21 12:04:23 +0000 | |
| commit | 53a0049dfb203e6f4f83a33ea0908eb593c1a29a (patch) | |
| tree | de0df5243bead334bb9f631cbac4163130d9b00b | |
| parent | 8b193f408875408b8776f2eeba9eed426d37eee5 (diff) | |
| parent | 2cc4eec9b93a5e29970c798920d2a74c8c642445 (diff) | |
Faster bugreports (4/n) am: 2cc4eec9b9
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1441345
Change-Id: Ie425f43a3a7707f7092b7bf06189120a92e371c4
| -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 b9dfbe02df..e8996d2736 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -3881,12 +3881,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); }; |