| 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 28 matching lines...) Expand all Loading... |
| 39 const int kNumTries = 100; | 39 const int kNumTries = 100; |
| 40 const int kIdleTimeMSec = 20; | 40 const int kIdleTimeMSec = 20; |
| 41 | 41 |
| 42 void InitLoggingForDaemon(const std::string& log_file) { | 42 void InitLoggingForDaemon(const std::string& log_file) { |
| 43 logging::LoggingSettings settings; | 43 logging::LoggingSettings settings; |
| 44 settings.logging_dest = | 44 settings.logging_dest = |
| 45 log_file.empty() ? | 45 log_file.empty() ? |
| 46 logging::LOG_TO_SYSTEM_DEBUG_LOG : logging::LOG_TO_FILE; | 46 logging::LOG_TO_SYSTEM_DEBUG_LOG : logging::LOG_TO_FILE; |
| 47 settings.log_file = log_file.c_str(); | 47 settings.log_file = log_file.c_str(); |
| 48 settings.lock_log = logging::DONT_LOCK_LOG_FILE; | 48 settings.lock_log = logging::DONT_LOCK_LOG_FILE; |
| 49 settings.dcheck_state = | |
| 50 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | |
| 51 CHECK(logging::InitLogging(settings)); | 49 CHECK(logging::InitLogging(settings)); |
| 52 } | 50 } |
| 53 | 51 |
| 54 bool RunServerAcceptLoop(const std::string& welcome_message, | 52 bool RunServerAcceptLoop(const std::string& welcome_message, |
| 55 Socket* server_socket, | 53 Socket* server_socket, |
| 56 Daemon::ServerDelegate* server_delegate) { | 54 Daemon::ServerDelegate* server_delegate) { |
| 57 bool failed = false; | 55 bool failed = false; |
| 58 for (;;) { | 56 for (;;) { |
| 59 scoped_ptr<Socket> client_socket(new Socket()); | 57 scoped_ptr<Socket> client_socket(new Socket()); |
| 60 if (!server_socket->Accept(client_socket.get())) { | 58 if (!server_socket->Accept(client_socket.get())) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return true; | 281 return true; |
| 284 } | 282 } |
| 285 usleep(kIdleTimeMSec * 1000); | 283 usleep(kIdleTimeMSec * 1000); |
| 286 } | 284 } |
| 287 LOG(ERROR) << "Timed out while killing daemon. " | 285 LOG(ERROR) << "Timed out while killing daemon. " |
| 288 "It might still be tearing down."; | 286 "It might still be tearing down."; |
| 289 return false; | 287 return false; |
| 290 } | 288 } |
| 291 | 289 |
| 292 } // namespace forwarder2 | 290 } // namespace forwarder2 |
| OLD | NEW |