From 5a05ef704e0f27e57af08695e01d8486f7f89af6 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Fri, 8 Oct 2021 17:33:47 -0700 Subject: 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 --- libs/binder/ServiceManagerHost.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libs/binder/ServiceManagerHost.cpp') 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 getDeviceService(std::vector&& serviceDispatcherArgs) { +sp getDeviceService(std::vector&& serviceDispatcherArgs, + const RpcDelegateServiceManagerOptions& options) { std::vector prefix{"adb", "shell", "servicedispatcher"}; serviceDispatcherArgs.insert(serviceDispatcherArgs.begin(), prefix.begin(), prefix.end()); @@ -158,6 +159,10 @@ sp getDeviceService(std::vector&& 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(), -- cgit v1.2.3-59-g8ed1b