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

Commit 2505ec42 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: remove global lock on proxy delete

We don't need a global lock here. Actually, it can be removed completely
(though that will have to be in a follow-up, it might require extra
allocations in some cases).

Bug: 192023359
Test: CtsNdkBinderTestCases
Change-Id: If5ad5acf003832fa69fe9c985a060feb53bea7af
parent 63a2d51e
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -232,19 +232,14 @@ ABpBinder::ABpBinder(const ::android::sp<::android::IBinder>& binder)
ABpBinder::~ABpBinder() {}

void ABpBinder::onLastStrongRef(const void* id) {
    {
        std::lock_guard<std::mutex> lock(ABpBinderTag::gLock);
    // Since ABpBinder is OBJECT_LIFETIME_WEAK, we must remove this weak reference in order for
    // the ABpBinder to be deleted. Since a strong reference to this ABpBinder object should no
    // longer be able to exist at the time of this method call, there is no longer a need to
    // recover it.

    ABpBinderTag::Value* value =
                static_cast<ABpBinderTag::Value*>(remote()->findObject(ABpBinderTag::kId));
        if (value != nullptr) {
            value->binder = nullptr;
        }
    }
            static_cast<ABpBinderTag::Value*>(remote()->detachObject(ABpBinderTag::kId));
    if (value) ABpBinderTag::clean(ABpBinderTag::kId, value, nullptr /*cookie*/);

    BpRefBase::onLastStrongRef(id);
}