costin 01/12/04 13:46:31 Modified: jk/native/common jk_jni_worker.c Log: Second patch from Julius Gawlas. Detect if the VM is already started and attach. Submitted by: "GAWLAS,JULIUS (HP-Cupertino,ex1)" <[EMAIL PROTECTED]> Revision Changes Path 1.8 +21 -4 jakarta-tomcat-connectors/jk/native/common/jk_jni_worker.c Index: jk_jni_worker.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_jni_worker.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- jk_jni_worker.c 2001/12/04 19:44:23 1.7 +++ jk_jni_worker.c 2001/12/04 21:46:30 1.8 @@ -59,7 +59,7 @@ * Description: In process JNI worker * * Author: Gal Shachor <[EMAIL PROTECTED]> * * Based on: * - * Version: $Revision: 1.7 $ * + * Version: $Revision: 1.8 $ * ***************************************************************************/ #if !defined(WIN32) && !defined(NETWARE) @@ -744,8 +744,10 @@ } else { jni_create_java_vm = dlsym(handle, "JNI_CreateJavaVM"); jni_get_default_java_vm_init_args = dlsym(handle, "JNI_GetDefaultJavaVMInitArgs"); + jni_get_created_java_vms = dlsym(hInst, "JNI_GetCreatedJavaVMs"); - if(jni_create_java_vm && jni_get_default_java_vm_init_args) { + if(jni_create_java_vm && jni_get_default_java_vm_init_args && + jni_get_created_java_vms) { jk_log(l, JK_LOG_DEBUG, "In load_jvm_dll, symbols resolved, done\n"); return JK_TRUE; @@ -918,7 +920,7 @@ jk_logger_t *l) { JavaVMInitArgs vm_args; - JNIEnv *penv; + JNIEnv *penv = NULL; JavaVMOption options[100]; int optn = 0, err; char* tmp; @@ -984,8 +986,23 @@ } jk_log(l, JK_LOG_DEBUG, "In open_jvm2, about to create JVM...\n"); + + err=jni_create_java_vm(&(p->jvm), &penv, &vm_args); + + if (JNI_EEXIST == err) { + int vmCount; + jk_log(l, JK_LOG_DEBUG, "JVM alread instantiated." + "Trying to attach instead.\n"); + + jni_get_created_java_vms(&(p->jvm), 1, &vmCount); + if (NULL != p->jvm) + penv = attach_to_jvm(p, l); + + if (NULL != penv) + err = 0; + } - if((err=jni_create_java_vm(&(p->jvm), &penv, &vm_args)) != 0) { + if(err != 0) { jk_log(l, JK_LOG_EMERG, "Fail-> could not create JVM, code: %d \n", err); return JK_FALSE; }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>