OSDN Git Service

Remove races from JNI_OnLoad invocation.
authorAndy McFadden <fadden@android.com>
Fri, 10 Jul 2009 00:01:04 +0000 (17:01 -0700)
committerAndy McFadden <fadden@android.com>
Fri, 10 Jul 2009 20:50:51 +0000 (13:50 -0700)
commit70318889578ab67943d6df29fedf09b11cfef015
tree25fff93561b633d426ac803dabaddb214460babf
parent160c5e674ff581736dcae27d2998cd294eaa294a
Remove races from JNI_OnLoad invocation.

The current implementation just calls JNI_OnLoad and returns a failure
result if that goes badly.  If a second load attempt is made after
dlopen() finishes but before JNI_OnLoad completes, it will succeed
immediately.

This is bad because (a) we might not have finished the initialization
steps in JNI_OnLoad, and (b) it's possible JNI_OnLoad will fail.  We now
wait for an in-progress JNI_OnLoad to complete before returning.  (This
also requires recognizing and handling recursive invocation.)
vm/Native.c