summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-06-02 18:37:42 +0000
committer Steven Moreland <smoreland@google.com> 2021-06-02 18:38:33 +0000
commit410325a0941c7aa2bb6f9854ee327edfaa55ba11 (patch)
tree92de59e7e30f7ac69c01be987fa6bbeeadb5939f
parent103424e021792e9e92728ff1d9a657a2f9ecd174 (diff)
libbinder: RpcServer: remove acceptOne
Singlely used function, no longer needed. Bug: N/A Test: binderRpcTest Change-Id: Id7fa463d532c997db78b5cf3eab5c7d8e8f17d51
-rw-r--r--libs/binder/RpcServer.cpp37
-rw-r--r--libs/binder/include/binder/RpcServer.h1
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;