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

Commit b2736551 authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge "adb: fix flakiness in PTY shell protocol."

parents fc4e54ec be41ae56
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -646,15 +646,21 @@ unique_fd* Subprocess::PollLoop(SubprocessPollfds* pfds) {
        }

        // After handling all of the events we've received, check to see if any fds have died.
        if (stdinout_pfd.revents & (POLLHUP | POLLRDHUP | POLLERR | POLLNVAL)) {
        auto poll_finished = [](int events) {
            // Don't return failure until we've read out all of the fd's incoming data.
            return (events & POLLIN) == 0 &&
                   (events & (POLLHUP | POLLRDHUP | POLLERR | POLLNVAL)) != 0;
        };

        if (poll_finished(stdinout_pfd.revents)) {
            return &stdinout_sfd_;
        }

        if (stderr_pfd.revents & (POLLHUP | POLLRDHUP | POLLERR | POLLNVAL)) {
        if (poll_finished(stderr_pfd.revents)) {
            return &stderr_sfd_;
        }

        if (protocol_pfd.revents & (POLLHUP | POLLRDHUP | POLLERR | POLLNVAL)) {
        if (poll_finished(protocol_pfd.revents)) {
            return &protocol_sfd_;
        }
    }  // while (!dead_sfd)