adb: bump the local socket backlog to the maximum.

The listen backlog seems to be more meaningful on Darwin than on Linux,
resulting in connections failing with ECONNRESET. Bump it up to the
maximum supported value to make this less likely. 128 pending
connections ought to be enough for anybody.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I5fe0205924188cf18ca1fc1204f923ab5523eeb2
(cherry picked from commit bf243a6128)
This commit is contained in:
Josh Gao 2018-03-20 14:25:03 -07:00
parent cc9414eda4
commit abb634308f
2 changed files with 2 additions and 5 deletions

View file

@ -105,8 +105,7 @@ static int _network_loopback_server(bool ipv6, int port, int type, std::string*
}
if (type == SOCK_STREAM || type == SOCK_SEQPACKET) {
// Arbitrarily selected value, ported from libcutils.
if (listen(s, 4) != 0) {
if (listen(s, SOMAXCONN) != 0) {
set_error(error);
return -1;
}

View file

@ -747,8 +747,6 @@ int network_loopback_client(int port, int type, std::string* error) {
return fd;
}
#define LISTEN_BACKLOG 4
// interface_address is INADDR_LOOPBACK or INADDR_ANY.
static int _network_server(int port, int type, u_long interface_address, std::string* error) {
struct sockaddr_in addr;
@ -805,7 +803,7 @@ static int _network_server(int port, int type, u_long interface_address, std::st
return -1;
}
if (type == SOCK_STREAM) {
if (listen(s, LISTEN_BACKLOG) == SOCKET_ERROR) {
if (listen(s, SOMAXCONN) == SOCKET_ERROR) {
const DWORD err = WSAGetLastError();
*error = android::base::StringPrintf(
"cannot listen on socket: %s", android::base::SystemErrorCodeToString(err).c_str());