binder: RpcSession::*MaxThreads -> *MaxIncomingThreads
We'll add a separate number for outgoing threads
Bug: 194225767
Test: pass
Change-Id: I7bf178c098adc6359582792a2f1ca1248a336b9f
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index 44b588b..967b8e3 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -381,7 +381,7 @@
} 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 37f6c7f..486b67b 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -76,18 +76,18 @@
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 @@
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 @@
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 ef62f20..9ba64f3 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -855,7 +855,7 @@
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 0fcee90..e64572b 100644
--- a/libs/binder/include/binder/RpcSession.h
+++ b/libs/binder/include/binder/RpcSession.h
@@ -59,7 +59,7 @@
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 @@
*
* 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 @@
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 a1058bc..2011801 100644
--- a/libs/binder/tests/binderRpcTest.cpp
+++ b/libs/binder/tests/binderRpcTest.cpp
@@ -613,7 +613,7 @@
status_t status;
for (const auto& session : sessions) {
- session->setMaxThreads(options.numIncomingConnections);
+ session->setMaxIncomingThreads(options.numIncomingConnections);
switch (socketType) {
case SocketType::PRECONNECTED: