From 9b7341fe57ee9e4e95b111a14966107b3f0582d0 Mon Sep 17 00:00:00 2001 From: Tao Wu Date: Wed, 21 Sep 2016 15:41:05 -0700 Subject: [PATCH] We should break from loop after getting connected. Now it always connects to multiple address of same host and just return one socket while other sockets get leaked. Also, it cause trouble on machine with dual stack. adb connect localhost:* just connect to IPv4 and IPv6 at same time and finally it doesn't work since emulator can only handle one adb connection. To test this, start an emulator with non-standar port and killall adb daemon on linux work station and then do following test. Test: adb connect localhost:12345;lsof -n -p `pgrep adb` Change-Id: I1e0f6824efc1db8e179377de068e3b5535aff3f7 --- libcutils/socket_network_client_unix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libcutils/socket_network_client_unix.c b/libcutils/socket_network_client_unix.c index 46818d695..37851b17a 100644 --- a/libcutils/socket_network_client_unix.c +++ b/libcutils/socket_network_client_unix.c @@ -112,6 +112,7 @@ int socket_network_client_timeout(const char* host, int port, int type, int time } result = toggle_O_NONBLOCK(s); + break; } freeaddrinfo(addrs);