tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_jni_worker.c
Date Tue, 04 Dec 2001 21:47:03 GMT
costin      01/12/04 13:47:03

  Modified:    jk/native2/common jk_jni_worker.c
  Log:
  Second patch from Julius Gawlas. ( now in jk2 )
  
  Detect if the VM is already started and attach.
  
  Submitted by:    "GAWLAS,JULIUS (HP-Cupertino,ex1)" <julius_gawlas@hp.com>
  
  Revision  Changes    Path
  1.4       +22 -7     jakarta-tomcat-connectors/jk/native2/common/jk_jni_worker.c
  
  Index: jk_jni_worker.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_jni_worker.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_jni_worker.c	2001/12/04 19:04:48	1.3
  +++ jk_jni_worker.c	2001/12/04 21:47:03	1.4
  @@ -59,7 +59,7 @@
    * Description: In process JNI worker                                      *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Based on:                                                               *
  - * Version:     $Revision: 1.3 $                                           *
  + * Version:     $Revision: 1.4 $                                           *
    ***************************************************************************/
   
   #if !defined(WIN32) && !defined(NETWARE)
  @@ -836,8 +836,10 @@
       } else {
           jni_create_java_vm = dlsym(handle, "JNI_CreateJavaVM");
           jni_get_default_java_vm_init_args = dlsym(handle, "JNI_GetDefaultJavaVMInitArgs");
  -
  -        if(jni_create_java_vm && jni_get_default_java_vm_init_args) {
  +        jni_get_created_java_vms =  dlsym(hInst, "JNI_GetCreatedJavaVMs");
  +        
  +        if(jni_create_java_vm && jni_get_default_java_vm_init_args
  +           && jni_get_created_java_vms) {
       	    l->jkLog(l, JK_LOG_DEBUG, 
                      "In load_jvm_dll, symbols resolved, done\n");
               return JK_TRUE;
  @@ -879,7 +881,7 @@
                       jk_logger_t *l)
   {
       JDK1_1InitArgs vm_args;  
  -    JNIEnv *penv;
  +    JNIEnv *penv = NULL;
       int err;
       *env = NULL;
   
  @@ -927,9 +929,22 @@
       }
   
       l->jkLog(l, JK_LOG_DEBUG, "In open_jvm1, about to create JVM...\n");
  -    if((err=jni_create_java_vm(&(p->jvm), 
  -                               &penv, 
  -                               &vm_args)) != 0) {
  +        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 != 0) {
   	    l->jkLog(l, JK_LOG_EMERG, 
                  "Fail-> could not create JVM, code: %d \n", err); 
           return JK_FALSE;
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message