|
@@ -522,19 +522,21 @@ JNIEnv* getJNIEnv(void)
|
|
|
/* Create a ThreadLocalState for this thread */
|
|
|
state = threadLocalStorageCreate();
|
|
|
if (!state) {
|
|
|
+ mutexUnlock(&jvmMutex);
|
|
|
fprintf(stderr, "getJNIEnv: Unable to create ThreadLocalState\n");
|
|
|
return NULL;
|
|
|
}
|
|
|
- state->env = getGlobalJNIEnv();
|
|
|
- mutexUnlock(&jvmMutex);
|
|
|
- if (!state->env) {
|
|
|
- goto fail;
|
|
|
- }
|
|
|
if (threadLocalStorageSet(state)) {
|
|
|
+ mutexUnlock(&jvmMutex);
|
|
|
goto fail;
|
|
|
}
|
|
|
THREAD_LOCAL_STORAGE_SET_QUICK(state);
|
|
|
|
|
|
+ state->env = getGlobalJNIEnv();
|
|
|
+ mutexUnlock(&jvmMutex);
|
|
|
+ if (!state->env) {
|
|
|
+ goto fail;
|
|
|
+ }
|
|
|
return state->env;
|
|
|
|
|
|
fail:
|