summaryrefslogtreecommitdiff
path: root/libs/binder/ServiceManagerHost.cpp
diff options
context:
space:
mode:
author Yifan Hong <elsk@google.com> 2021-10-08 17:33:47 -0700
committer Yifan Hong <elsk@google.com> 2021-10-11 16:43:40 -0700
commit5a05ef704e0f27e57af08695e01d8486f7f89af6 (patch)
treee8a2ba49f8bd99036f5eda0f36d35cfc5560597e /libs/binder/ServiceManagerHost.cpp
parent1f44f98dcd552f820a5e115e5f977cd15ae0eae5 (diff)
binder: host service manager limits max outgoing threads
... for each returned binder object. By default, the limit is SIZE_MAX. Test: aservice ... with max outgoing threads = 1, `aservice list` takes 19s. ... with max outgoing threads = SIZE_MAX, `aservice list` takes 30s. Test: binderHostDeviceTest Fixes: 194225767 Change-Id: Ib51fa41970fff804f40b7604a6a195ce0b16f89d
Diffstat (limited to 'libs/binder/ServiceManagerHost.cpp')
-rw-r--r--libs/binder/ServiceManagerHost.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libs/binder/ServiceManagerHost.cpp b/libs/binder/ServiceManagerHost.cpp
index 27cc563adc..194254ac69 100644
--- a/libs/binder/ServiceManagerHost.cpp
+++ b/libs/binder/ServiceManagerHost.cpp
@@ -124,7 +124,8 @@ void cleanupCommandResult(const void* id, void* obj, void* /* cookie */) {
} // namespace
-sp<IBinder> getDeviceService(std::vector<std::string>&& serviceDispatcherArgs) {
+sp<IBinder> getDeviceService(std::vector<std::string>&& serviceDispatcherArgs,
+ const RpcDelegateServiceManagerOptions& options) {
std::vector<std::string> prefix{"adb", "shell", "servicedispatcher"};
serviceDispatcherArgs.insert(serviceDispatcherArgs.begin(), prefix.begin(), prefix.end());
@@ -158,6 +159,10 @@ sp<IBinder> getDeviceService(std::vector<std::string>&& serviceDispatcherArgs) {
LOG_ALWAYS_FATAL_IF(!forwardResult->hostPort().has_value());
auto rpcSession = RpcSession::make();
+ if (options.maxOutgoingThreads.has_value()) {
+ rpcSession->setMaxOutgoingThreads(*options.maxOutgoingThreads);
+ }
+
if (status_t status = rpcSession->setupInetClient("127.0.0.1", *forwardResult->hostPort());
status != OK) {
ALOGE("Unable to set up inet client on host port %u: %s", *forwardResult->hostPort(),