Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome_watchdog.cc

Issue 6012007: wm: Fix FD leak in watchdog when Chrome is hanging. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/window_manager.git@master
Patch Set: fix typo in comment Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome_watchdog_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome_watchdog_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698