Loading adb/daemon/transport_qemu.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ void qemu_socket_thread(int port) { /* This could be an older version of the emulator, that doesn't * implement adb QEMUD service. Fall back to the old TCP way. */ D("adb service is not available. Falling back to TCP socket."); std::thread(server_socket_thread, android::base::StringPrintf("tcp:%d", port)).detach(); std::thread(server_socket_thread, tcp_listen_inaddr_any, port).detach(); return; } Loading adb/sysdeps/posix/network.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <string> #include <android-base/logging.h> #include <android-base/stringprintf.h> #include <cutils/sockets.h> #include "adb_unique_fd.h" Loading Loading @@ -136,11 +137,13 @@ int network_connect(const std::string& host, int port, int type, int timeout, st return fd; } if (getaddrinfo_error != 0) { *error = gai_strerror(getaddrinfo_error); LOG(WARNING) << "failed to resolve host '" << host << "': " << *error; *error = android::base::StringPrintf("failed to resolve host: '%s': %s", host.c_str(), gai_strerror(getaddrinfo_error)); LOG(WARNING) << *error; } else { *error = strerror(errno); LOG(WARNING) << "failed to connect to '" << host << "': " << *error; *error = android::base::StringPrintf("failed to connect to '%s:%d': %s", host.c_str(), port, strerror(errno)); LOG(WARNING) << *error; } return -1; } adb/transport.h +2 −1 Original line number Diff line number Diff line Loading @@ -401,7 +401,8 @@ void send_packet(apacket* p, atransport* t); asocket* create_device_tracker(bool long_output); #if !ADB_HOST void server_socket_thread(std::string_view spec); unique_fd tcp_listen_inaddr_any(int port, std::string* error); void server_socket_thread(std::function<unique_fd(int, std::string*)> listen_func, int port); #if defined(__ANDROID__) void qemu_socket_thread(int port); Loading adb/transport_local.cpp +22 −12 Original line number Diff line number Diff line Loading @@ -236,16 +236,15 @@ static void client_socket_thread(int) { #else // !ADB_HOST void server_socket_thread(std::string_view spec) { void server_socket_thread(std::function<unique_fd(int, std::string*)> listen_func, int port) { adb_thread_setname("server socket"); unique_fd serverfd; std::string error; adb_thread_setname("server socket"); D("transport: server_socket_thread() starting"); int port; while (serverfd == -1) { std::string error; errno = 0; serverfd.reset(socket_spec_listen(spec, &error, &port)); serverfd = listen_func(port, &error); if (errno == EAFNOSUPPORT || errno == EINVAL || errno == EPROTONOSUPPORT) { D("unrecoverable error: '%s'", error.c_str()); return; Loading @@ -258,8 +257,7 @@ void server_socket_thread(std::string_view spec) { } while (true) { std::string spec_str{spec}; D("server: trying to get new connection from %s", spec_str.c_str()); D("server: trying to get new connection from fd %d", serverfd.get()); unique_fd fd(adb_socket_accept(serverfd, nullptr, nullptr)); if (fd >= 0) { D("server: new connection on fd %d", fd.get()); Loading @@ -275,6 +273,18 @@ void server_socket_thread(std::string_view spec) { #endif unique_fd tcp_listen_inaddr_any(int port, std::string* error) { return unique_fd{network_inaddr_any_server(port, SOCK_STREAM, error)}; } #if !ADB_HOST static unique_fd vsock_listen(int port, std::string* error) { return unique_fd{ socket_spec_listen(android::base::StringPrintf("vsock:%d", port), error, nullptr) }; } #endif void local_init(int port) { #if ADB_HOST D("transport: local client init"); Loading @@ -282,8 +292,8 @@ void local_init(int port) { #elif !defined(__ANDROID__) // Host adbd. D("transport: local server init"); std::thread(server_socket_thread, android::base::StringPrintf("tcp:%d", port)).detach(); std::thread(server_socket_thread, android::base::StringPrintf("vsock:%d", port)).detach(); std::thread(server_socket_thread, tcp_listen_inaddr_any, port).detach(); std::thread(server_socket_thread, vsock_listen, port).detach(); #else D("transport: local server init"); // For the adbd daemon in the system image we need to distinguish Loading @@ -291,9 +301,9 @@ void local_init(int port) { if (use_qemu_goldfish()) { std::thread(qemu_socket_thread, port).detach(); } else { std::thread(server_socket_thread, android::base::StringPrintf("tcp:%d", port)).detach(); std::thread(server_socket_thread, tcp_listen_inaddr_any, port).detach(); } std::thread(server_socket_thread, android::base::StringPrintf("vsock:%d", port)).detach(); std::thread(server_socket_thread, vsock_listen, port).detach(); #endif // !ADB_HOST } Loading Loading
adb/daemon/transport_qemu.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ void qemu_socket_thread(int port) { /* This could be an older version of the emulator, that doesn't * implement adb QEMUD service. Fall back to the old TCP way. */ D("adb service is not available. Falling back to TCP socket."); std::thread(server_socket_thread, android::base::StringPrintf("tcp:%d", port)).detach(); std::thread(server_socket_thread, tcp_listen_inaddr_any, port).detach(); return; } Loading
adb/sysdeps/posix/network.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <string> #include <android-base/logging.h> #include <android-base/stringprintf.h> #include <cutils/sockets.h> #include "adb_unique_fd.h" Loading Loading @@ -136,11 +137,13 @@ int network_connect(const std::string& host, int port, int type, int timeout, st return fd; } if (getaddrinfo_error != 0) { *error = gai_strerror(getaddrinfo_error); LOG(WARNING) << "failed to resolve host '" << host << "': " << *error; *error = android::base::StringPrintf("failed to resolve host: '%s': %s", host.c_str(), gai_strerror(getaddrinfo_error)); LOG(WARNING) << *error; } else { *error = strerror(errno); LOG(WARNING) << "failed to connect to '" << host << "': " << *error; *error = android::base::StringPrintf("failed to connect to '%s:%d': %s", host.c_str(), port, strerror(errno)); LOG(WARNING) << *error; } return -1; }
adb/transport.h +2 −1 Original line number Diff line number Diff line Loading @@ -401,7 +401,8 @@ void send_packet(apacket* p, atransport* t); asocket* create_device_tracker(bool long_output); #if !ADB_HOST void server_socket_thread(std::string_view spec); unique_fd tcp_listen_inaddr_any(int port, std::string* error); void server_socket_thread(std::function<unique_fd(int, std::string*)> listen_func, int port); #if defined(__ANDROID__) void qemu_socket_thread(int port); Loading
adb/transport_local.cpp +22 −12 Original line number Diff line number Diff line Loading @@ -236,16 +236,15 @@ static void client_socket_thread(int) { #else // !ADB_HOST void server_socket_thread(std::string_view spec) { void server_socket_thread(std::function<unique_fd(int, std::string*)> listen_func, int port) { adb_thread_setname("server socket"); unique_fd serverfd; std::string error; adb_thread_setname("server socket"); D("transport: server_socket_thread() starting"); int port; while (serverfd == -1) { std::string error; errno = 0; serverfd.reset(socket_spec_listen(spec, &error, &port)); serverfd = listen_func(port, &error); if (errno == EAFNOSUPPORT || errno == EINVAL || errno == EPROTONOSUPPORT) { D("unrecoverable error: '%s'", error.c_str()); return; Loading @@ -258,8 +257,7 @@ void server_socket_thread(std::string_view spec) { } while (true) { std::string spec_str{spec}; D("server: trying to get new connection from %s", spec_str.c_str()); D("server: trying to get new connection from fd %d", serverfd.get()); unique_fd fd(adb_socket_accept(serverfd, nullptr, nullptr)); if (fd >= 0) { D("server: new connection on fd %d", fd.get()); Loading @@ -275,6 +273,18 @@ void server_socket_thread(std::string_view spec) { #endif unique_fd tcp_listen_inaddr_any(int port, std::string* error) { return unique_fd{network_inaddr_any_server(port, SOCK_STREAM, error)}; } #if !ADB_HOST static unique_fd vsock_listen(int port, std::string* error) { return unique_fd{ socket_spec_listen(android::base::StringPrintf("vsock:%d", port), error, nullptr) }; } #endif void local_init(int port) { #if ADB_HOST D("transport: local client init"); Loading @@ -282,8 +292,8 @@ void local_init(int port) { #elif !defined(__ANDROID__) // Host adbd. D("transport: local server init"); std::thread(server_socket_thread, android::base::StringPrintf("tcp:%d", port)).detach(); std::thread(server_socket_thread, android::base::StringPrintf("vsock:%d", port)).detach(); std::thread(server_socket_thread, tcp_listen_inaddr_any, port).detach(); std::thread(server_socket_thread, vsock_listen, port).detach(); #else D("transport: local server init"); // For the adbd daemon in the system image we need to distinguish Loading @@ -291,9 +301,9 @@ void local_init(int port) { if (use_qemu_goldfish()) { std::thread(qemu_socket_thread, port).detach(); } else { std::thread(server_socket_thread, android::base::StringPrintf("tcp:%d", port)).detach(); std::thread(server_socket_thread, tcp_listen_inaddr_any, port).detach(); } std::thread(server_socket_thread, android::base::StringPrintf("vsock:%d", port)).detach(); std::thread(server_socket_thread, vsock_listen, port).detach(); #endif // !ADB_HOST } Loading