diff options
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r-- | libs/binder/RpcSession.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index 771d738579..0ea761918e 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -127,7 +127,7 @@ void RpcSession::FdTrigger::trigger() { bool RpcSession::FdTrigger::triggerablePollRead(base::borrowed_fd fd) { while (true) { - pollfd pfd[]{{.fd = fd.get(), .events = POLLIN, .revents = 0}, + pollfd pfd[]{{.fd = fd.get(), .events = POLLIN | POLLHUP, .revents = 0}, {.fd = mRead.get(), .events = POLLHUP, .revents = 0}}; int ret = TEMP_FAILURE_RETRY(poll(pfd, arraysize(pfd), -1)); if (ret < 0) { @@ -140,7 +140,7 @@ bool RpcSession::FdTrigger::triggerablePollRead(base::borrowed_fd fd) { if (pfd[1].revents & POLLHUP) { return false; } - return true; + return pfd[0].revents & POLLIN; } } @@ -150,6 +150,8 @@ bool RpcSession::FdTrigger::interruptableRecv(base::borrowed_fd fd, void* data, while (triggerablePollRead(fd)) { ssize_t readSize = TEMP_FAILURE_RETRY(recv(fd.get(), buffer, end - buffer, MSG_NOSIGNAL)); + if (readSize == 0) return false; // EOF + if (readSize < 0) { ALOGE("Failed to read %s", strerror(errno)); return false; |