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

Change-Id: I41c65bed67ceb644cf9d115bbc70883e16933dd9
This commit is contained in:
Josh Gao 2020-05-20 21:25:27 +00:00 committed by Automerger Merge Worker
commit 9e3e8c40e2

View file

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