diff options
| author | 2019-07-10 10:53:50 -0700 | |
|---|---|---|
| committer | 2019-07-10 10:53:50 -0700 | |
| commit | 16fba9486da3d12e9db81cc202bf4ef73f17c748 (patch) | |
| tree | 67c1c196cc60a0af213e965abf2d37c3c0bd46f1 | |
| parent | c22c5994847e86d7d900a9e6fa3f472ecad59854 (diff) | |
| parent | e1dcef20148af6cd19b4a4c82de0d98e88d7bf19 (diff) | |
Merge "binder: Bp: clear DRs in onLastStrongRef" am: 6c1517874d
am: e1dcef2014
Change-Id: I18a0c110bd3f48d13f0d34e099e7215b93d6286f
| -rw-r--r-- | libs/binder/BpBinder.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp index ec170f7a65..67f968aea0 100644 --- a/libs/binder/BpBinder.cpp +++ b/libs/binder/BpBinder.cpp @@ -387,21 +387,6 @@ BpBinder::~BpBinder() } } - mLock.lock(); - Vector<Obituary>* obits = mObituaries; - if(obits != nullptr) { - if (ipc) ipc->clearDeathNotification(mHandle, this); - mObituaries = nullptr; - } - mLock.unlock(); - - if (obits != nullptr) { - // XXX Should we tell any remaining DeathRecipient - // objects that the last strong ref has gone away, so they - // are no longer linked? - delete obits; - } - if (ipc) { ipc->expungeHandle(mHandle, this); ipc->decWeakHandle(mHandle); @@ -423,6 +408,25 @@ void BpBinder::onLastStrongRef(const void* /*id*/) } IPCThreadState* ipc = IPCThreadState::self(); if (ipc) ipc->decStrongHandle(mHandle); + + mLock.lock(); + Vector<Obituary>* obits = mObituaries; + if(obits != nullptr) { + if (!obits->isEmpty()) { + ALOGI("onLastStrongRef automatically unlinking death recipients"); + } + + if (ipc) ipc->clearDeathNotification(mHandle, this); + mObituaries = nullptr; + } + mLock.unlock(); + + if (obits != nullptr) { + // XXX Should we tell any remaining DeathRecipient + // objects that the last strong ref has gone away, so they + // are no longer linked? + delete obits; + } } bool BpBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/) |