diff options
author | 2020-08-21 14:48:20 +0800 | |
---|---|---|
committer | 2020-10-19 04:09:00 +0000 | |
commit | e96bcd52a008a25139acf07050a6dc3a5d153009 (patch) | |
tree | 0fe568743c3755a717052c4f4fed82dbea8a1038 | |
parent | 6f5ddce79411d17b2d69646cbc1188449bceab57 (diff) |
Deletes temporary files from thread pool when report is cancel
Bug: 163027506
Test: atest dumpstate_test
Test: atest dumpstate_smoke_test
Test: Manual cancel the bureport from notification.
Change-Id: Ic4ab0531e0f598c2d2b820293cd2e6444bbf1abb
Merged-In: Ic4ab0531e0f598c2d2b820293cd2e6444bbf1abb
(cherry picked from commit 0daac91e7b4b2b9a108be1f57dd77c9813abb90f)
-rw-r--r-- | cmds/dumpstate/DumpPool.cpp | 4 | ||||
-rw-r--r-- | cmds/dumpstate/DumpPool.h | 5 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 9 |
3 files changed, 18 insertions, 0 deletions
diff --git a/cmds/dumpstate/DumpPool.cpp b/cmds/dumpstate/DumpPool.cpp index e174c8eff3..e15ac3fe82 100644 --- a/cmds/dumpstate/DumpPool.cpp +++ b/cmds/dumpstate/DumpPool.cpp @@ -100,6 +100,10 @@ void DumpPool::waitForTask(const std::string& task_name, const std::string& titl } } +void DumpPool::deleteTempFiles() { + deleteTempFiles(tmp_root_); +} + void DumpPool::setLogDuration(bool log_duration) { log_duration_ = log_duration; } diff --git a/cmds/dumpstate/DumpPool.h b/cmds/dumpstate/DumpPool.h index a4ea875541..0c3c2cc0d7 100644 --- a/cmds/dumpstate/DumpPool.h +++ b/cmds/dumpstate/DumpPool.h @@ -134,6 +134,11 @@ class DumpPool { */ void waitForTask(const std::string& task_name, const std::string& title, int out_fd); + /* + * Deletes temporary files created by DumpPool. + */ + void deleteTempFiles(); + static const std::string PREFIX_TMPFILE_NAME; private: diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 0fba40e2e7..eefc84f0f1 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -2689,6 +2689,15 @@ void Dumpstate::Cancel() { } tombstone_data_.clear(); anr_data_.clear(); + + // Instead of shutdown the pool, we delete temporary files directly since + // shutdown blocking the call. + if (dump_pool_) { + dump_pool_->deleteTempFiles(); + } + if (zip_entry_tasks_) { + zip_entry_tasks_->run(/*do_cancel =*/ true); + } } /* |