aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-07 22:20:56 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-07 22:20:56 +0000
commit7074c958df99a91784759b0ed950e9958ef20b5f (patch)
tree790d939aa65ad043194b9604e8fe13b68d862955
parentb666183ac7ea645012b43410f03f0d1233f8d82e (diff)
parentb887dc0b5c5ac8ffa993a1ac6899ae92b6dbe8cb (diff)
downloadbionic-7074c958df99a91784759b0ed950e9958ef20b5f.tar.gz
Snap for 7434874 from b887dc0b5c5ac8ffa993a1ac6899ae92b6dbe8cb to sc-mainline-release
Change-Id: I52de31e1c51ee42a65aa06b0e4908cf1bedbe796
-rw-r--r--libc/bionic/malloc_heapprofd.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp
index 198bcbab7..741b45e98 100644
--- a/libc/bionic/malloc_heapprofd.cpp
+++ b/libc/bionic/malloc_heapprofd.cpp
@@ -325,12 +325,12 @@ void HeapprofdRememberHookConflict() {
static void CommonInstallHooks(libc_globals* globals) {
void* impl_handle = atomic_load(&gHeapprofdHandle);
- bool reusing_handle = impl_handle != nullptr;
- if (!reusing_handle) {
+ if (impl_handle == nullptr) {
impl_handle = LoadSharedLibrary(kHeapprofdSharedLib, kHeapprofdPrefix, &globals->malloc_dispatch_table);
if (impl_handle == nullptr) {
return;
}
+ atomic_store(&gHeapprofdHandle, impl_handle);
} else if (!InitSharedLibrary(impl_handle, kHeapprofdSharedLib, kHeapprofdPrefix, &globals->malloc_dispatch_table)) {
return;
}
@@ -341,11 +341,7 @@ static void CommonInstallHooks(libc_globals* globals) {
// MaybeModifyGlobals locks at this point.
atomic_store(&gPreviousDefaultDispatchTable, GetDefaultDispatchTable());
- if (FinishInstallHooks(globals, nullptr, kHeapprofdPrefix)) {
- atomic_store(&gHeapprofdHandle, impl_handle);
- } else if (!reusing_handle) {
- dlclose(impl_handle);
- }
+ FinishInstallHooks(globals, nullptr, kHeapprofdPrefix);
}
void HeapprofdInstallHooksAtInit(libc_globals* globals) {