summaryrefslogtreecommitdiff
path: root/libs/binder/RpcSession.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-06-02 18:16:19 +0000
committer Steven Moreland <smoreland@google.com> 2021-06-02 18:17:51 +0000
commit103424e021792e9e92728ff1d9a657a2f9ecd174 (patch)
treed9c766df473f9a4867dff9b9135542cd61a65fd3 /libs/binder/RpcSession.cpp
parente54384bbd4d4c3b433b180e8f25c15266ae21228 (diff)
libbinder: RPC more symmetrical max threads
Now, RpcServer and RpcSession both keep track of their max threads using the same variable, and the server can therefore request the number of reverse connections possible. Bug: 185167543 Test: N/A Change-Id: Ieaff69c8c2da2faf7598aed7e862601a1fcd7a00
Diffstat (limited to 'libs/binder/RpcSession.cpp')
-rw-r--r--libs/binder/RpcSession.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index a3efa56e3b..a27dff5c8f 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -59,15 +59,18 @@ sp<RpcSession> RpcSession::make() {
return sp<RpcSession>::make();
}
-void RpcSession::setMaxReverseConnections(size_t connections) {
- {
- std::lock_guard<std::mutex> _l(mMutex);
- LOG_ALWAYS_FATAL_IF(mClientConnections.size() != 0,
- "Must setup reverse connections before setting up client connections, "
- "but already has %zu clients",
- mClientConnections.size());
- }
- mMaxReverseConnections = connections;
+void RpcSession::setMaxThreads(size_t threads) {
+ std::lock_guard<std::mutex> _l(mMutex);
+ LOG_ALWAYS_FATAL_IF(!mClientConnections.empty() || !mServerConnections.empty(),
+ "Must set max threads before setting up connections, but has %zu client(s) "
+ "and %zu server(s)",
+ mClientConnections.size(), mServerConnections.size());
+ mMaxThreads = threads;
+}
+
+size_t RpcSession::getMaxThreads() {
+ std::lock_guard<std::mutex> _l(mMutex);
+ return mMaxThreads;
}
bool RpcSession::setupUnixDomainClient(const char* path) {
@@ -309,7 +312,7 @@ bool RpcSession::setupSocketClient(const RpcSocketAddress& addr) {
// requested to be set) in order to allow the other side to reliably make
// any requests at all.
- for (size_t i = 0; i < mMaxReverseConnections; i++) {
+ for (size_t i = 0; i < mMaxThreads; i++) {
if (!setupOneSocketConnection(addr, mId.value(), true /*reverse*/)) return false;
}