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

Commit 823e96e2 authored by Mike Lockwood's avatar Mike Lockwood Committed by Android (Google) Code Review
Browse files

Merge "adb: kick the transport after sending the "adb root" command"

parents 28e08dc5 d15e6ac9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -86,6 +86,12 @@ struct asocket {
        */
    int    closing;

        /* flag: kick the transport when the socket is closed.
        ** This is needed to handle commands that cause the
        ** remote daemon to terminate, like "adb root"
        */
    int    kick_on_close;

        /* the asocket we are connected to
        */

+16 −0
Original line number Diff line number Diff line
@@ -190,6 +190,14 @@ static void local_socket_ready(asocket *s)

static void local_socket_close(asocket *s)
{
#if ADB_HOST
    /* to special case commands that cause the remote daemon to terminate */
    if (s->kick_on_close && s->transport) {
        kick_transport(s->transport);
        /* delay to work around a race condition */
        sleep(1);
    }
#endif
    adb_mutex_lock(&socket_list_lock);
    local_socket_close_locked(s);
    adb_mutex_unlock(&socket_list_lock);
@@ -524,6 +532,14 @@ void connect_to_remote(asocket *s, const char *destination)
    apacket *p = get_apacket();
    int len = strlen(destination) + 1;

#if ADB_HOST
    /* special case commands that cause the remote daemon to terminate */
    if (!strcmp(destination, "root:")) {
        D("connect_to_remote setting kick_on_close for %s\n", destination);
        s->kick_on_close = 1;
    }
#endif

    if(len > (MAX_PAYLOAD-1)) {
        fatal("destination oversized");
    }