summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryawanng <yawanng@google.com>2020-06-20 05:01:21 +0000
committeryawanng <yawanng@google.com>2020-06-22 18:09:33 +0000
commit2c3b9c0082cb729eecf10cb008bd9c4f4ff93a2b (patch)
tree5efd21c428d07be6da38823f3ea4505e67cb772f
parent1a4822dd45b8d18f9a8db87b41ab0218fb23aec6 (diff)
downloadiorap-2c3b9c0082cb729eecf10cb008bd9c4f4ff93a2b.tar.gz
maintenance: Fix the dangling reference to function parameters.
Bug: 158488480 Test: Run iorap on cuttlefish. Change-Id: I6b54221d88324d82431f1099453618ec2fc0c0ce
-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;
}