Index: remoting/host/daemon_process.cc |
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc |
index 8c7cf67c7a6643dbc0d20e9d27d11f7d73fd8a29..1a601902c20453df9c41417d8e589740adcf5451 100644 |
--- a/remoting/host/daemon_process.cc |
+++ b/remoting/host/daemon_process.cc |
@@ -174,6 +174,9 @@ void DaemonProcess::CreateDesktopSession(int terminal_id, |
bool virtual_terminal) { |
DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
+ // Terminal IDs cannot be reused. Update the expected next terminal ID. |
+ next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); |
+ |
// Validate the supplied terminal ID. An attempt to create a desktop session |
// with an ID that could possibly have been allocated already is considered |
// a protocol error and the network process will be restarted. |
@@ -202,18 +205,15 @@ void DaemonProcess::CreateDesktopSession(int terminal_id, |
// Create the desktop session. |
scoped_ptr<DesktopSession> session = DoCreateDesktopSession( |
terminal_id, params, virtual_terminal); |
- if (session) { |
- VLOG(1) << "Daemon: opened desktop session " << terminal_id; |
- desktop_sessions_.push_back(session.release()); |
- } else { |
+ if (!session) { |
LOG(ERROR) << "Failed to create a desktop session."; |
SendToNetwork( |
new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
return; |
} |
- // Update the expected terminal ID. |
- next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); |
+ VLOG(1) << "Daemon: opened desktop session " << terminal_id; |
+ desktop_sessions_.push_back(session.release()); |
} |
void DaemonProcess::CrashNetworkProcess( |