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

Side by Side Diff: tools/android/forwarder2/daemon.cc

Issue 18635005: Reland "Add --serial-id option to host_forwarder." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 months 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 | « build/android/pylib/forwarder.py ('k') | tools/android/forwarder2/device_forwarder_main.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) 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 "tools/android/forwarder2/daemon.h" 5 #include "tools/android/forwarder2/daemon.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <sys/file.h> 10 #include <sys/file.h>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 for (int i = 0; i < tries_count; ++i) { 134 for (int i = 0; i < tries_count; ++i) {
135 scoped_ptr<Socket> socket(new Socket()); 135 scoped_ptr<Socket> socket(new Socket());
136 if (!socket->ConnectUnix(socket_name)) { 136 if (!socket->ConnectUnix(socket_name)) {
137 if (idle_time_msec) 137 if (idle_time_msec)
138 usleep(idle_time_msec * 1000); 138 usleep(idle_time_msec * 1000);
139 continue; 139 continue;
140 } 140 }
141 char buf[kBufferSize]; 141 char buf[kBufferSize];
142 DCHECK(expected_welcome_message.length() + 1 <= sizeof(buf)); 142 DCHECK(expected_welcome_message.length() + 1 <= sizeof(buf));
143 memset(buf, 0, sizeof(buf)); 143 memset(buf, 0, sizeof(buf));
144 if (socket->Read(buf, sizeof(buf)) < 0) { 144 if (socket->Read(buf, expected_welcome_message.length() + 1) < 0) {
145 perror("read"); 145 perror("read");
146 continue; 146 continue;
147 } 147 }
148 if (expected_welcome_message != buf) { 148 if (expected_welcome_message != buf) {
149 LOG(ERROR) << "Unexpected message read from daemon: " << buf; 149 LOG(ERROR) << "Unexpected message read from daemon: " << buf;
150 break; 150 break;
151 } 151 }
152 return socket.Pass(); 152 return socket.Pass();
153 } 153 }
154 return scoped_ptr<Socket>(); 154 return scoped_ptr<Socket>();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return true; 280 return true;
281 } 281 }
282 usleep(kIdleTimeMSec * 1000); 282 usleep(kIdleTimeMSec * 1000);
283 } 283 }
284 LOG(ERROR) << "Timed out while killing daemon. " 284 LOG(ERROR) << "Timed out while killing daemon. "
285 "It might still be tearing down."; 285 "It might still be tearing down.";
286 return false; 286 return false;
287 } 287 }
288 288
289 } // namespace forwarder2 289 } // namespace forwarder2
OLDNEW
« no previous file with comments | « build/android/pylib/forwarder.py ('k') | tools/android/forwarder2/device_forwarder_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698