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

Side by Side Diff: remoting/host/daemon_process.cc

Issue 11234034: Crash the network process when a fatal daemon-to-network protocol error encountered. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 "remoting/host/daemon_process.h" 5 #include "remoting/host/daemon_process.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void DaemonProcess::CloseDesktopSession(int terminal_id) { 73 void DaemonProcess::CloseDesktopSession(int terminal_id) {
74 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 74 DCHECK(caller_task_runner()->BelongsToCurrentThread());
75 75
76 // Validate the supplied terminal ID. An attempt to close a desktop session 76 // Validate the supplied terminal ID. An attempt to close a desktop session
77 // with an ID that couldn't possibly have been allocated is considered 77 // with an ID that couldn't possibly have been allocated is considered
78 // a protocol error and the network process will be restarted. 78 // a protocol error and the network process will be restarted.
79 if (!IsTerminalIdKnown(terminal_id)) { 79 if (!IsTerminalIdKnown(terminal_id)) {
80 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; 80 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id;
81 RestartNetworkProcess(); 81 RestartNetworkProcess(FROM_HERE);
82 DeleteAllDesktopSessions(); 82 DeleteAllDesktopSessions();
83 return; 83 return;
84 } 84 }
85 85
86 DesktopSessionList::iterator i; 86 DesktopSessionList::iterator i;
87 for (i = desktop_sessions_.begin(); i != desktop_sessions_.end(); ++i) { 87 for (i = desktop_sessions_.begin(); i != desktop_sessions_.end(); ++i) {
88 if ((*i)->id() == terminal_id) { 88 if ((*i)->id() == terminal_id) {
89 break; 89 break;
90 } 90 }
91 } 91 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 void DaemonProcess::CreateDesktopSession(int terminal_id) { 143 void DaemonProcess::CreateDesktopSession(int terminal_id) {
144 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 144 DCHECK(caller_task_runner()->BelongsToCurrentThread());
145 145
146 // Validate the supplied terminal ID. An attempt to create a desktop session 146 // Validate the supplied terminal ID. An attempt to create a desktop session
147 // with an ID that could possibly have been allocated already is considered 147 // with an ID that could possibly have been allocated already is considered
148 // a protocol error and the network process will be restarted. 148 // a protocol error and the network process will be restarted.
149 if (IsTerminalIdKnown(terminal_id)) { 149 if (IsTerminalIdKnown(terminal_id)) {
150 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; 150 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id;
151 RestartNetworkProcess(); 151 RestartNetworkProcess(FROM_HERE);
152 DeleteAllDesktopSessions(); 152 DeleteAllDesktopSessions();
153 return; 153 return;
154 } 154 }
155 155
156 VLOG(1) << "Daemon: opened desktop session " << terminal_id; 156 VLOG(1) << "Daemon: opened desktop session " << terminal_id;
157 desktop_sessions_.push_back( 157 desktop_sessions_.push_back(
158 DoCreateDesktopSession(terminal_id).release()); 158 DoCreateDesktopSession(terminal_id).release());
159 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); 159 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1);
160 } 160 }
161 161
162 void DaemonProcess::RestartNetworkProcess(
Wez 2012/10/23 20:01:12 nit: CrashAndRestartNetworkProcess
alexeypa (please no reviews) 2012/10/23 20:13:27 It is CrashNetworkProcess() then. Because someone
163 const tracked_objects::Location& location) {
164 SendToNetwork(new ChromotingDaemonNetworkMsg_Crash(
165 location.function_name(), location.file_name(), location.line_number()));
166 }
167
162 void DaemonProcess::DoStop() { 168 void DaemonProcess::DoStop() {
163 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 169 DCHECK(caller_task_runner()->BelongsToCurrentThread());
164 170
165 config_watcher_.reset(); 171 config_watcher_.reset();
166 DeleteAllDesktopSessions(); 172 DeleteAllDesktopSessions();
167 173
168 CompleteStopping(); 174 CompleteStopping();
169 } 175 }
170 176
171 void DaemonProcess::DeleteAllDesktopSessions() { 177 void DaemonProcess::DeleteAllDesktopSessions() {
172 while (!desktop_sessions_.empty()) { 178 while (!desktop_sessions_.empty()) {
173 delete desktop_sessions_.front(); 179 delete desktop_sessions_.front();
174 desktop_sessions_.pop_front(); 180 desktop_sessions_.pop_front();
175 } 181 }
176 } 182 }
177 183
178 } // namespace remoting 184 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698