diff options
| -rw-r--r-- | libs/binder/RpcTransportTipcAndroid.cpp | 8 | ||||
| -rw-r--r-- | libs/binder/trusty/RpcTransportTipcTrusty.cpp | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/libs/binder/RpcTransportTipcAndroid.cpp b/libs/binder/RpcTransportTipcAndroid.cpp index 453279c0a5..8b3ddfbd6f 100644 --- a/libs/binder/RpcTransportTipcAndroid.cpp +++ b/libs/binder/RpcTransportTipcAndroid.cpp @@ -63,12 +63,14 @@ public: if (pfd.revents & POLLERR) { return DEAD_OBJECT; } - if (pfd.revents & POLLHUP) { - return DEAD_OBJECT; - } if (pfd.revents & POLLIN) { + // Copied from FdTrigger.cpp: Even though POLLHUP may also be set, + // treat it as a success condition to ensure data is drained. return OK; } + if (pfd.revents & POLLHUP) { + return DEAD_OBJECT; + } return WOULD_BLOCK; } diff --git a/libs/binder/trusty/RpcTransportTipcTrusty.cpp b/libs/binder/trusty/RpcTransportTipcTrusty.cpp index 58bfe71211..d249b2e1eb 100644 --- a/libs/binder/trusty/RpcTransportTipcTrusty.cpp +++ b/libs/binder/trusty/RpcTransportTipcTrusty.cpp @@ -239,6 +239,12 @@ private: } if (!(uevt.event & IPC_HANDLE_POLL_MSG)) { /* No message, terminate here and leave mHaveMessage false */ + if (uevt.event & IPC_HANDLE_POLL_HUP) { + // Peer closed the connection. We need to preserve the order + // between MSG and HUP from FdTrigger.cpp, which means that + // getting MSG&HUP should return OK instead of DEAD_OBJECT. + return DEAD_OBJECT; + } return OK; } |