diff options
-rw-r--r-- | libs/binder/RpcServer.cpp | 2 | ||||
-rw-r--r-- | libs/binder/RpcSession.cpp | 18 | ||||
-rw-r--r-- | libs/binder/RpcState.cpp | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/RpcSession.h | 8 | ||||
-rw-r--r-- | libs/binder/tests/binderRpcTest.cpp | 2 |
5 files changed, 16 insertions, 16 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index 44b588be00..967b8e3801 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -381,7 +381,7 @@ void RpcServer::establishConnection(sp<RpcServer>&& server, base::unique_fd clie } while (server->mSessions.end() != server->mSessions.find(sessionId)); session = RpcSession::make(); - session->setMaxThreads(server->mMaxThreads); + session->setMaxIncomingThreads(server->mMaxThreads); if (!session->setProtocolVersion(protocolVersion)) return; if (!session->setForServer(server, sp<RpcServer::EventListener>::fromExisting( diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index 37f6c7ff45..486b67b62c 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -76,18 +76,18 @@ sp<RpcSession> RpcSession::make(std::unique_ptr<RpcTransportCtxFactory> rpcTrans return sp<RpcSession>::make(std::move(ctx)); } -void RpcSession::setMaxThreads(size_t threads) { +void RpcSession::setMaxIncomingThreads(size_t threads) { std::lock_guard<std::mutex> _l(mMutex); LOG_ALWAYS_FATAL_IF(!mConnections.mOutgoing.empty() || !mConnections.mIncoming.empty(), - "Must set max threads before setting up connections, but has %zu client(s) " - "and %zu server(s)", + "Must set max incoming threads before setting up connections, but has %zu " + "client(s) and %zu server(s)", mConnections.mOutgoing.size(), mConnections.mIncoming.size()); - mMaxThreads = threads; + mMaxIncomingThreads = threads; } -size_t RpcSession::getMaxThreads() { +size_t RpcSession::getMaxIncomingThreads() { std::lock_guard<std::mutex> _l(mMutex); - return mMaxThreads; + return mMaxIncomingThreads; } bool RpcSession::setProtocolVersion(uint32_t version) { @@ -484,7 +484,7 @@ status_t RpcSession::setupClient(const std::function<status_t(const std::vector< if (status_t status = connectAndInit(mId, false /*incoming*/); status != OK) return status; } - for (size_t i = 0; i < mMaxThreads; i++) { + for (size_t i = 0; i < mMaxIncomingThreads; i++) { if (status_t status = connectAndInit(mId, true /*incoming*/); status != OK) return status; } @@ -697,9 +697,9 @@ sp<RpcSession::RpcConnection> RpcSession::assignIncomingConnectionToThisThread( std::unique_ptr<RpcTransport> rpcTransport) { std::lock_guard<std::mutex> _l(mMutex); - if (mConnections.mIncoming.size() >= mMaxThreads) { + if (mConnections.mIncoming.size() >= mMaxIncomingThreads) { ALOGE("Cannot add thread to session with %zu threads (max is set to %zu)", - mConnections.mIncoming.size(), mMaxThreads); + mConnections.mIncoming.size(), mMaxIncomingThreads); return nullptr; } diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index ef62f20d9a..9ba64f3407 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -855,7 +855,7 @@ processTransactInternalTailCall: switch (transaction->code) { case RPC_SPECIAL_TRANSACT_GET_MAX_THREADS: { - replyStatus = reply.writeInt32(session->getMaxThreads()); + replyStatus = reply.writeInt32(session->getMaxIncomingThreads()); break; } case RPC_SPECIAL_TRANSACT_GET_SESSION_ID: { diff --git a/libs/binder/include/binder/RpcSession.h b/libs/binder/include/binder/RpcSession.h index 0fcee90ed6..e64572b234 100644 --- a/libs/binder/include/binder/RpcSession.h +++ b/libs/binder/include/binder/RpcSession.h @@ -59,7 +59,7 @@ public: static sp<RpcSession> make(std::unique_ptr<RpcTransportCtxFactory> rpcTransportCtxFactory); /** - * Set the maximum number of threads allowed to be made (for things like callbacks). + * Set the maximum number of incoming threads allowed to be made (for things like callbacks). * By default, this is 0. This must be called before setting up this connection as a client. * Server sessions will inherits this value from RpcServer. * @@ -68,8 +68,8 @@ public: * * TODO(b/189955605): start these dynamically */ - void setMaxThreads(size_t threads); - size_t getMaxThreads(); + void setMaxIncomingThreads(size_t threads); + size_t getMaxIncomingThreads(); /** * By default, the minimum of the supported versions of the client and the @@ -307,7 +307,7 @@ private: std::mutex mMutex; // for all below - size_t mMaxThreads = 0; + size_t mMaxIncomingThreads = 0; std::optional<uint32_t> mProtocolVersion; std::condition_variable mAvailableConnectionCv; // for mWaitingThreads diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index a1058bced6..2011801f27 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -613,7 +613,7 @@ public: status_t status; for (const auto& session : sessions) { - session->setMaxThreads(options.numIncomingConnections); + session->setMaxIncomingThreads(options.numIncomingConnections); switch (socketType) { case SocketType::PRECONNECTED: |