diff options
author | 2021-12-10 08:41:54 +0000 | |
---|---|---|
committer | 2021-12-23 04:42:05 +0000 | |
commit | a39e4edeaa1635a6d6246bb9de470f046e4856e9 (patch) | |
tree | 4337a39f0b2fd9a61fcf1f8df2bef7745c5ba4fe /libs/binder/RpcSession.cpp | |
parent | 3183b5c2ccb259ec218420c8bfcd8f7e4f45c05e (diff) |
binder: Eliminate a data copy in RPC transport operations
Switch RpcTransportRaw to use sendmsg() and recvmsg() over
iovecs to send data from multiple buffers to avoid having
to copy all data into a single large buffer.
Bug: 202878542
Test: atest binderRpcTest
Change-Id: I8ba7fa815040555503160ae41888a0b0efe9e5d2
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r-- | libs/binder/RpcSession.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index a5a2bb1017..b84395e7cb 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -615,8 +615,9 @@ status_t RpcSession::initAndAddConnection(unique_fd fd, const std::vector<uint8_ header.options |= RPC_CONNECTION_OPTION_INCOMING; } + iovec headerIov{&header, sizeof(header)}; auto sendHeaderStatus = - server->interruptableWriteFully(mShutdownTrigger.get(), &header, sizeof(header), {}); + server->interruptableWriteFully(mShutdownTrigger.get(), &headerIov, 1, {}); if (sendHeaderStatus != OK) { ALOGE("Could not write connection header to socket: %s", statusToString(sendHeaderStatus).c_str()); @@ -624,9 +625,10 @@ status_t RpcSession::initAndAddConnection(unique_fd fd, const std::vector<uint8_ } if (sessionId.size() > 0) { + iovec sessionIov{const_cast<void*>(static_cast<const void*>(sessionId.data())), + sessionId.size()}; auto sendSessionIdStatus = - server->interruptableWriteFully(mShutdownTrigger.get(), sessionId.data(), - sessionId.size(), {}); + server->interruptableWriteFully(mShutdownTrigger.get(), &sessionIov, 1, {}); if (sendSessionIdStatus != OK) { ALOGE("Could not write session ID ('%s') to socket: %s", base::HexString(sessionId.data(), sessionId.size()).c_str(), |