| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "window_manager/chrome_watchdog.h" | 5 #include "window_manager/chrome_watchdog.h" |
| 6 | 6 |
| 7 #include <csignal> | 7 #include <csignal> |
| 8 | 8 |
| 9 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 registrar_->UnregisterForWindowEvents(wm_->root()); | 106 registrar_->UnregisterForWindowEvents(wm_->root()); |
| 107 pinged_chrome_xid_ = 0; | 107 pinged_chrome_xid_ = 0; |
| 108 ping_timestamp_ = 0; | 108 ping_timestamp_ = 0; |
| 109 wm_->event_loop()->RemoveTimeout(timeout_id_); | 109 wm_->event_loop()->RemoveTimeout(timeout_id_); |
| 110 timeout_id_ = -1; | 110 timeout_id_ = -1; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ChromeWatchdog::HandleTimeout() { | 113 void ChromeWatchdog::HandleTimeout() { |
| 114 DCHECK(has_outstanding_ping()); | 114 DCHECK(has_outstanding_ping()); |
| 115 registrar_->UnregisterForWindowEvents(wm_->root()); | 115 DCHECK(pinged_chrome_xid_); |
| 116 ping_timestamp_ = 0; | 116 Window* win = wm_->GetWindowOrDie(pinged_chrome_xid_); |
| 117 timeout_id_ = -1; | 117 AbortTimeout(); |
| 118 | 118 |
| 119 Window* win = wm_->GetWindowOrDie(pinged_chrome_xid_); | |
| 120 pid_t chrome_pid = static_cast<pid_t>(win->client_pid()); | 119 pid_t chrome_pid = static_cast<pid_t>(win->client_pid()); |
| 121 | |
| 122 LOG(INFO) << "Chrome window " << win->xid_str() << " didn't respond to ping; " | 120 LOG(INFO) << "Chrome window " << win->xid_str() << " didn't respond to ping; " |
| 123 << (!FLAGS_kill_chrome_if_hanging ? "(not really) " : "") | 121 << (!FLAGS_kill_chrome_if_hanging ? "(not really) " : "") |
| 124 << "sending signal " << kSignalToSend << " to PID " << chrome_pid; | 122 << "sending signal " << kSignalToSend << " to PID " << chrome_pid; |
| 125 if (FLAGS_kill_chrome_if_hanging && is_pid_valid(chrome_pid)) { | 123 if (FLAGS_kill_chrome_if_hanging && is_pid_valid(chrome_pid)) { |
| 126 if (kill(chrome_pid, kSignalToSend) != 0) | 124 if (kill(chrome_pid, kSignalToSend) != 0) |
| 127 PLOG(ERROR) << "Unable to kill Chrome PID " << chrome_pid; | 125 PLOG(ERROR) << "Unable to kill Chrome PID " << chrome_pid; |
| 128 } | 126 } |
| 129 | 127 |
| 130 last_killed_pid_ = chrome_pid; | 128 last_killed_pid_ = chrome_pid; |
| 131 pinged_chrome_xid_ = 0; | |
| 132 } | 129 } |
| 133 | 130 |
| 134 } // namespace window_manager | 131 } // namespace window_manager |
| OLD | NEW |