Fixes dumpstate crashed when shutdown the thread pool
The future of the packaged_task should be cleared before we
clear the packaged_task in the task queue.
Bug: 182798355
Test: atest DumpPoolTest#ShutdownBeforeTasksFinished_withoutCrash
Change-Id: I85e6aca67c61629d786f0586c6fe3d714f400233
diff --git a/cmds/dumpstate/DumpPool.cpp b/cmds/dumpstate/DumpPool.cpp
index e15ac3f..c2c8a72 100644
--- a/cmds/dumpstate/DumpPool.cpp
+++ b/cmds/dumpstate/DumpPool.cpp
@@ -64,8 +64,8 @@
if (shutdown_ || threads_.empty()) {
return;
}
- while (!tasks_.empty()) tasks_.pop();
futures_map_.clear();
+ while (!tasks_.empty()) tasks_.pop();
shutdown_ = true;
condition_variable_.notify_all();