Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2124f89 authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "libfakeservicemanager: no hold lock in clear" into main

parents e068703c 95ac79e9
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -122,10 +122,20 @@ std::vector<IServiceManager::ServiceDebugInfo> FakeServiceManager::getServiceDeb
}

void FakeServiceManager::clear() {
    std::lock_guard<std::mutex> l(mMutex);
    std::map<String16, sp<IBinder>> backup;

    {
      std::lock_guard<std::mutex> l(mMutex);
      backup = mNameToService;
      mNameToService.clear();
    }

    // destructors may access FSM, so avoid recursive lock
    backup.clear(); // explicit

    // TODO: destructors may have added more services here - may want
    // to check this or abort
}
}  // namespace android

[[clang::no_destroy]] static sp<FakeServiceManager> gFakeServiceManager;