diff options
author | 2024-10-27 12:01:38 -0700 | |
---|---|---|
committer | 2024-10-28 20:02:43 +0000 | |
commit | fe6dff869704dcdf5c0554f88ce784a516557241 (patch) | |
tree | 70e2f681ddcd4082cd4588af397dd5db02ea2804 | |
parent | 1f9c184392020cb5c4bdf453f4c8847ca389614b (diff) |
Do not defer library unloading from zygote
This is a minor update to aosp/3320321 (with the correct bug number).
No problems were observed, but the change seemed to be a bit dangerous
in a zygote.
Test: Treehugger
Bug: 374209523
Change-Id: Id414059ad775319422f678326c3d2009cfd413cc
-rw-r--r-- | runtime/jni/java_vm_ext.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc index 3012539b3c..2c17537636 100644 --- a/runtime/jni/java_vm_ext.cc +++ b/runtime/jni/java_vm_ext.cc @@ -358,6 +358,11 @@ class Libraries { int retries = 0; static constexpr int MAX_RETRIES = 5; while (!Locks::jni_libraries_lock_->ExclusiveTryLock(self)) { + if (Runtime::Current()->IsZygote()) { + // Do not risk deferring to the child processes. + Locks::jni_libraries_lock_->ExclusiveLock(self); + break; + } if (++retries > MAX_RETRIES) { // We do not want to block indefinitely here, for fear of timeouts. See b/374209523. LOG(WARNING) << "Deferring native library unloading due to contention"; |