ServiceManager: Check guaranteeClient before unregistering services
If tryUnregisterService is called while a service has set guaranteeClient to true, it should not succeed. The flag means that a client exists and is about to be counted. Not checking this flag can lead to a race. Bug: 151485917 Test: aidl_lazy_test Change-Id: If7ef7a5c7521ea40521bd351385fb8bd650aba08
This commit is contained in:
parent
a4b4999ec5
commit
bb108a1839
1 changed files with 5 additions and 0 deletions
|
@ -522,6 +522,11 @@ Status ServiceManager::tryUnregisterService(const std::string& name, const sp<IB
|
|||
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
|
||||
}
|
||||
|
||||
if (serviceIt->second.guaranteeClient) {
|
||||
LOG(INFO) << "Tried to unregister " << name << ", but there is about to be a client.";
|
||||
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
|
||||
}
|
||||
|
||||
int clients = handleServiceClientCallback(name, false);
|
||||
|
||||
// clients < 0: feature not implemented or other error. Assume clients.
|
||||
|
|
Loading…
Reference in a new issue