summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryawanng <yawanng@google.com>2020-06-22 20:36:17 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-22 20:36:17 +0000
commit82a0ea914bbdb3189503726fc86b3408f3e0b86b (patch)
tree5efd21c428d07be6da38823f3ea4505e67cb772f
parentd7fd059414baae21421ff9b0870f2412768502a7 (diff)
parent2c3b9c0082cb729eecf10cb008bd9c4f4ff93a2b (diff)
downloadiorap-82a0ea914bbdb3189503726fc86b3408f3e0b86b.tar.gz
maintenance: Fix the dangling reference to function parameters. am: 2c3b9c0082
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/iorap/+/11931583 Change-Id: I75a3ae2e484972f053c18ea368d3ae989bbd34e7
-rw-r--r--src/maintenance/controller.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/maintenance/controller.cc b/src/maintenance/controller.cc
index 6ba119c..639f402 100644
--- a/src/maintenance/controller.cc
+++ b/src/maintenance/controller.cc
@@ -128,7 +128,7 @@ std::vector<std::string> MakeCompilerParams(const CompilerForkParameters& params
// Sets a watch dog for the given pid and kill it if timeout.
std::thread SetTimeoutWatchDog(pid_t pid, int64_t timeout_ms, std::atomic<bool>& cancel_watchdog) {
- std::thread watchdog_thread{[&]() {
+ std::thread watchdog_thread{[pid, timeout_ms, &cancel_watchdog]() {
std::chrono::time_point start = std::chrono::system_clock::now();
std::chrono::milliseconds timeout(timeout_ms);
while (!cancel_watchdog) {
@@ -140,6 +140,12 @@ std::thread SetTimeoutWatchDog(pid_t pid, int64_t timeout_ms, std::atomic<bool>&
std::chrono::time_point cur = std::chrono::system_clock::now();
if (cur - start > timeout) {
LOG(INFO) << "Process (" << pid << ") is timeout!";
+ LOG(INFO) << "start time: "
+ << std::chrono::system_clock::to_time_t(start)
+ << " end time: "
+ << std::chrono::system_clock::to_time_t(cur)
+ << " timeout: "
+ << timeout_ms;
kill(pid, SIGKILL);
break;
}