Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf243a61 authored by Josh Gao's avatar Josh Gao
Browse files

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
parent 2c621ae7
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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;
        }
+1 −3
Original line number Diff line number Diff line
@@ -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());