diff options
| author | 2022-12-14 00:03:35 +0000 | |
|---|---|---|
| committer | 2022-12-14 00:03:35 +0000 | |
| commit | 8b2e672a2ac28c9bad29f3f8e02c2fb4a5a63ce4 (patch) | |
| tree | 3fe172615f6b6a47244848464ed91191fbb3d926 | |
| parent | c4bbf5ceb55c7e8f14f25c4e1d987fde9759583f (diff) | |
| parent | c0e7936dd06f271443cd8f5f9d38e02a6fdc7267 (diff) | |
Merge "libbinder: Handle peer closing connection in Trusty" am: a1cf02cf50 am: c0e7936dd0
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2336530
Change-Id: I313f60528415b1e98d841286c52519fbb4121722
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -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; } |