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
This commit is contained in:
Tao Wu 2016-09-21 15:41:05 -07:00
parent 4159568548
commit 9b7341fe57
1 changed files with 1 additions and 0 deletions

View File

@ -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);