summaryrefslogtreecommitdiff
path: root/libs/binder/IServiceManager.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/IServiceManager.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/IServiceManager.cpp')
-rw-r--r--libs/binder/IServiceManager.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index aff9e0d48d..81e61daae1 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -448,21 +448,27 @@ std::optional<IServiceManager::ConnectionInfo> ServiceManagerShim::getConnection
// on-device service manager.
class ServiceManagerHostShim : public ServiceManagerShim {
public:
- using ServiceManagerShim::ServiceManagerShim;
+ ServiceManagerHostShim(const sp<AidlServiceManager>& impl,
+ const RpcDelegateServiceManagerOptions& options)
+ : ServiceManagerShim(impl), mOptions(options) {}
// ServiceManagerShim::getService is based on checkService, so no need to override it.
sp<IBinder> checkService(const String16& name) const override {
- return getDeviceService({String8(name).c_str()});
+ return getDeviceService({String8(name).c_str()}, mOptions);
}
protected:
// Override realGetService for ServiceManagerShim::waitForService.
Status realGetService(const std::string& name, sp<IBinder>* _aidl_return) {
- *_aidl_return = getDeviceService({"-g", name});
+ *_aidl_return = getDeviceService({"-g", name}, mOptions);
return Status::ok();
}
+
+private:
+ RpcDelegateServiceManagerOptions mOptions;
};
-sp<IServiceManager> createRpcDelegateServiceManager() {
- auto binder = getDeviceService({"manager"});
+sp<IServiceManager> createRpcDelegateServiceManager(
+ const RpcDelegateServiceManagerOptions& options) {
+ auto binder = getDeviceService({"manager"}, options);
if (binder == nullptr) {
ALOGE("getDeviceService(\"manager\") returns null");
return nullptr;
@@ -472,7 +478,7 @@ sp<IServiceManager> createRpcDelegateServiceManager() {
ALOGE("getDeviceService(\"manager\") returns non service manager");
return nullptr;
}
- return sp<ServiceManagerHostShim>::make(interface);
+ return sp<ServiceManagerHostShim>::make(interface, options);
}
#endif