summaryrefslogtreecommitdiff
path: root/libs/binder/RpcSession.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-05-20 01:22:58 +0000
committer Steven Moreland <smoreland@google.com> 2021-05-21 02:07:19 +0000
commit9d11b9238d21eb09b978927ff6c4460d4f01be42 (patch)
treec694c828f01f29c8d2aabd9191cb273386cf9f7f /libs/binder/RpcSession.cpp
parentc77116c37c623c2b2d138717a6d9b16a85e08429 (diff)
libbinder: RpcServer - shutdown connection threads
Re-use FdTrigger to shutdown connection threads. Coming next - shutting down sessions as well! Bug: 185167543 Test: binderRpcTest, binder_rpc_fuzzer Change-Id: I238f1e2a5f69fdec09ac8b3afc484ab8639852fa
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r--libs/binder/RpcSession.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index ea82f36400..771d738579 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -144,6 +144,22 @@ bool RpcSession::FdTrigger::triggerablePollRead(base::borrowed_fd fd) {
}
}
+bool RpcSession::FdTrigger::interruptableRecv(base::borrowed_fd fd, void* data, size_t size) {
+ uint8_t* buffer = reinterpret_cast<uint8_t*>(data);
+ uint8_t* end = buffer + size;
+
+ while (triggerablePollRead(fd)) {
+ ssize_t readSize = TEMP_FAILURE_RETRY(recv(fd.get(), buffer, end - buffer, MSG_NOSIGNAL));
+ if (readSize < 0) {
+ ALOGE("Failed to read %s", strerror(errno));
+ return false;
+ }
+ buffer += readSize;
+ if (buffer == end) return true;
+ }
+ return false;
+}
+
status_t RpcSession::readId() {
{
std::lock_guard<std::mutex> _l(mMutex);