OLD | NEW |
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (socket->Read(buf, sizeof(buf)) < 0) { | 144 if (socket->Read(buf, sizeof(buf)) < 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>(NULL); | 154 return scoped_ptr<Socket>(); |
155 } | 155 } |
156 | 156 |
157 } // namespace | 157 } // namespace |
158 | 158 |
159 Daemon::Daemon(const std::string& log_file_path, | 159 Daemon::Daemon(const std::string& log_file_path, |
160 const std::string& identifier, | 160 const std::string& identifier, |
161 ClientDelegate* client_delegate, | 161 ClientDelegate* client_delegate, |
162 ServerDelegate* server_delegate, | 162 ServerDelegate* server_delegate, |
163 GetExitNotifierFDCallback get_exit_fd_callback) | 163 GetExitNotifierFDCallback get_exit_fd_callback) |
164 : log_file_path_(log_file_path), | 164 : log_file_path_(log_file_path), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |