diff options
-rw-r--r-- | libs/binder/RpcServer.cpp | 37 | ||||
-rw-r--r-- | libs/binder/include/binder/RpcServer.h | 1 |
2 files changed, 16 insertions, 22 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index 5ffee0600f..2f378dadce 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -153,7 +153,22 @@ void RpcServer::join() { status_t status; while ((status = mShutdownTrigger->triggerablePollRead(mServer)) == OK) { - (void)acceptOne(); + unique_fd clientFd(TEMP_FAILURE_RETRY( + accept4(mServer.get(), nullptr, nullptr /*length*/, SOCK_CLOEXEC))); + + if (clientFd < 0) { + ALOGE("Could not accept4 socket: %s", strerror(errno)); + continue; + } + LOG_RPC_DETAIL("accept4 on fd %d yields fd %d", mServer.get(), clientFd.get()); + + { + std::lock_guard<std::mutex> _l(mLock); + std::thread thread = + std::thread(&RpcServer::establishConnection, sp<RpcServer>::fromExisting(this), + std::move(clientFd)); + mConnectingThreads[thread.get_id()] = std::move(thread); + } } LOG_RPC_DETAIL("RpcServer::join exiting with %s", statusToString(status).c_str()); @@ -164,26 +179,6 @@ void RpcServer::join() { mShutdownCv.notify_all(); } -bool RpcServer::acceptOne() { - unique_fd clientFd( - TEMP_FAILURE_RETRY(accept4(mServer.get(), nullptr, nullptr /*length*/, SOCK_CLOEXEC))); - - if (clientFd < 0) { - ALOGE("Could not accept4 socket: %s", strerror(errno)); - return false; - } - LOG_RPC_DETAIL("accept4 on fd %d yields fd %d", mServer.get(), clientFd.get()); - - { - std::lock_guard<std::mutex> _l(mLock); - std::thread thread = std::thread(&RpcServer::establishConnection, - sp<RpcServer>::fromExisting(this), std::move(clientFd)); - mConnectingThreads[thread.get_id()] = std::move(thread); - } - - return true; -} - bool RpcServer::shutdown() { std::unique_lock<std::mutex> _l(mLock); if (mShutdownTrigger == nullptr) { diff --git a/libs/binder/include/binder/RpcServer.h b/libs/binder/include/binder/RpcServer.h index 0082ec324d..98db2212f2 100644 --- a/libs/binder/include/binder/RpcServer.h +++ b/libs/binder/include/binder/RpcServer.h @@ -160,7 +160,6 @@ private: static void establishConnection(sp<RpcServer>&& server, base::unique_fd clientFd); bool setupSocketServer(const RpcSocketAddress& address); - [[nodiscard]] bool acceptOne(); bool mAgreedExperimental = false; size_t mMaxThreads = 1; |