diff options
| author | 2022-11-11 23:33:20 +0000 | |
|---|---|---|
| committer | 2022-11-11 23:33:20 +0000 | |
| commit | 28987cfe8f45330896ab55d916ac823978aa0e4f (patch) | |
| tree | 3b345aae517bcb477132a7a615688eb0a0d2417f /libs/binder/RpcServer.cpp | |
| parent | 5528738f5729dd2a5b4e04877d281aea8e7a615b (diff) | |
| parent | ffb1209149ed834c5cfc30e0f3c3503bf7f63154 (diff) | |
Merge "[rpc_binder] Implement RPC binder over init-managed Unix domain socket" am: 213454462c am: ffb1209149
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2267564
Change-Id: I1b241c478845433d1172df2464b266be8ead4ef2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs/binder/RpcServer.cpp')
| -rw-r--r-- | libs/binder/RpcServer.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index 83d0de7835..399667d02b 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -564,6 +564,29 @@ status_t RpcServer::setupSocketServer(const RpcSocketAddress& addr) { return OK; } +status_t RpcServer::setupRawSocketServer(base::unique_fd socket_fd) { + RpcTransportFd transportFd(std::move(socket_fd)); + if (!transportFd.fd.ok()) { + int savedErrno = errno; + ALOGE("Could not get initialized Unix socket: %s", strerror(savedErrno)); + return -savedErrno; + } + // Right now, we create all threads at once, making accept4 slow. To avoid hanging the client, + // the backlog is increased to a large number. + // TODO(b/189955605): Once we create threads dynamically & lazily, the backlog can be reduced + // to 1. + if (0 != TEMP_FAILURE_RETRY(listen(transportFd.fd.get(), 50 /*backlog*/))) { + int savedErrno = errno; + ALOGE("Could not listen initialized Unix socket: %s", strerror(savedErrno)); + return -savedErrno; + } + if (status_t status = setupExternalServer(std::move(transportFd.fd)); status != OK) { + ALOGE("Another thread has set up server while calling setupSocketServer. Race?"); + return status; + } + return OK; +} + void RpcServer::onSessionAllIncomingThreadsEnded(const sp<RpcSession>& session) { const std::vector<uint8_t>& id = session->mId; LOG_ALWAYS_FATAL_IF(id.empty(), "Server sessions must be initialized with ID"); |