summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/android/forwarder2/device_controller.cc12
-rw-r--r--tools/android/forwarder2/device_controller.h4
-rw-r--r--tools/android/forwarder2/device_forwarder_main.cc7
3 files changed, 14 insertions, 9 deletions
diff --git a/tools/android/forwarder2/device_controller.cc b/tools/android/forwarder2/device_controller.cc
index c7acca3..ff4470a 100644
--- a/tools/android/forwarder2/device_controller.cc
+++ b/tools/android/forwarder2/device_controller.cc
@@ -45,13 +45,17 @@ void DeviceController::KillAllListeners() {
}
}
-bool DeviceController::Start(const std::string& adb_unix_socket) {
+bool DeviceController::Init(const std::string& adb_unix_socket) {
if (!kickstart_adb_socket_.BindUnix(adb_unix_socket,
true /* abstract */)) {
- LOG(ERROR) << "Could not BindAndListen DeviceController socket on port: "
- << adb_unix_socket;
+ LOG(ERROR) << "Could not BindAndListen DeviceController socket on port "
+ << adb_unix_socket << ": " << safe_strerror(errno);
return false;
}
+ return true;
+}
+
+void DeviceController::Start() {
while (true) {
CleanUpDeadListeners();
scoped_ptr<Socket> socket(new Socket);
@@ -124,8 +128,6 @@ bool DeviceController::Start(const std::string& adb_unix_socket) {
KillAllListeners();
CleanUpDeadListeners();
kickstart_adb_socket_.Close();
-
- return true;
}
} // namespace forwarder
diff --git a/tools/android/forwarder2/device_controller.h b/tools/android/forwarder2/device_controller.h
index 213cb8a8..4c36698 100644
--- a/tools/android/forwarder2/device_controller.h
+++ b/tools/android/forwarder2/device_controller.h
@@ -22,7 +22,9 @@ class DeviceController {
explicit DeviceController(int exit_notifier_fd);
~DeviceController();
- bool Start(const std::string& adb_unix_socket);
+ bool Init(const std::string& adb_unix_socket);
+
+ void Start();
private:
void KillAllListeners();
diff --git a/tools/android/forwarder2/device_forwarder_main.cc b/tools/android/forwarder2/device_forwarder_main.cc
index 481cde4..c0142a1 100644
--- a/tools/android/forwarder2/device_forwarder_main.cc
+++ b/tools/android/forwarder2/device_forwarder_main.cc
@@ -8,8 +8,8 @@
#include <string>
-#include "base/logging.h"
#include "base/command_line.h"
+#include "base/logging.h"
#include "base/stringprintf.h"
#include "tools/android/common/daemon.h"
#include "tools/android/forwarder2/device_controller.h"
@@ -58,8 +58,9 @@ int main(int argc, char** argv) {
signal(SIGINT, KillHandler);
CHECK(g_notifier);
forwarder2::DeviceController controller(g_notifier->receiver_fd());
+ if (!controller.Init(adb_socket_path))
+ return 1;
printf("Starting Device Forwarder.\n");
- controller.Start(adb_socket_path);
-
+ controller.Start();
return 0;
}