Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
art
Commits
727d6dff
Commit
727d6dff
authored
9 years ago
by
Mathieu Chartier
Browse files
Options
Download
Email Patches
Plain Diff
Revert "Revert "(dl)Close native libraries on unload""
This reverts commit
0cf0dbd5
.
parent
b652da7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
runtime/java_vm_ext.cc
runtime/java_vm_ext.cc
+17
-14
No files found.
runtime/java_vm_ext.cc
View file @
727d6dff
...
...
@@ -74,6 +74,10 @@ class SharedLibrary {
if
(
self
!=
nullptr
)
{
self
->
GetJniEnv
()
->
DeleteWeakGlobalRef
(
class_loader_
);
}
if
(
!
needs_native_bridge_
)
{
android
::
CloseNativeLibrary
(
handle_
);
}
}
jweak
GetClassLoader
()
const
{
...
...
@@ -271,8 +275,7 @@ class Libraries {
REQUIRES
(
!
Locks
::
jni_libraries_lock_
)
SHARED_REQUIRES
(
Locks
::
mutator_lock_
)
{
ScopedObjectAccessUnchecked
soa
(
Thread
::
Current
());
typedef
void
(
*
JNI_OnUnloadFn
)(
JavaVM
*
,
void
*
);
std
::
vector
<
JNI_OnUnloadFn
>
unload_functions
;
std
::
vector
<
SharedLibrary
*>
unload_libraries
;
{
MutexLock
mu
(
soa
.
Self
(),
*
Locks
::
jni_libraries_lock_
);
for
(
auto
it
=
libraries_
.
begin
();
it
!=
libraries_
.
end
();
)
{
...
...
@@ -283,15 +286,7 @@ class Libraries {
// the native libraries of the boot class loader.
if
(
class_loader
!=
nullptr
&&
soa
.
Self
()
->
IsJWeakCleared
(
class_loader
))
{
void
*
const
sym
=
library
->
FindSymbol
(
"JNI_OnUnload"
,
nullptr
);
if
(
sym
==
nullptr
)
{
VLOG
(
jni
)
<<
"[No JNI_OnUnload found in
\"
"
<<
library
->
GetPath
()
<<
"
\"
]"
;
}
else
{
VLOG
(
jni
)
<<
"[JNI_OnUnload found for
\"
"
<<
library
->
GetPath
()
<<
"
\"
]"
;
JNI_OnUnloadFn
jni_on_unload
=
reinterpret_cast
<
JNI_OnUnloadFn
>
(
sym
);
unload_functions
.
push_back
(
jni_on_unload
);
}
delete
library
;
unload_libraries
.
push_back
(
library
);
it
=
libraries_
.
erase
(
it
);
}
else
{
++
it
;
...
...
@@ -299,9 +294,17 @@ class Libraries {
}
}
// Do this without holding the jni libraries lock to prevent possible deadlocks.
for
(
JNI_OnUnloadFn
fn
:
unload_functions
)
{
VLOG
(
jni
)
<<
"Calling JNI_OnUnload"
;
(
*
fn
)(
soa
.
Vm
(),
nullptr
);
typedef
void
(
*
JNI_OnUnloadFn
)(
JavaVM
*
,
void
*
);
for
(
auto
library
:
unload_libraries
)
{
void
*
const
sym
=
library
->
FindSymbol
(
"JNI_OnUnload"
,
nullptr
);
if
(
sym
==
nullptr
)
{
VLOG
(
jni
)
<<
"[No JNI_OnUnload found in
\"
"
<<
library
->
GetPath
()
<<
"
\"
]"
;
}
else
{
VLOG
(
jni
)
<<
"[JNI_OnUnload found for
\"
"
<<
library
->
GetPath
()
<<
"
\"
]: Calling..."
;
JNI_OnUnloadFn
jni_on_unload
=
reinterpret_cast
<
JNI_OnUnloadFn
>
(
sym
);
jni_on_unload
(
soa
.
Vm
(),
nullptr
);
}
delete
library
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment