tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_vm_default.c
Date Thu, 24 Oct 2002 15:37:18 GMT
mturk       2002/10/24 08:37:18

  Modified:    jk/native2/common jk_vm_default.c
  Log:
  After guessing JVM check if the file is inside the
  LD_LIBRARY_PATH.
  
  Revision  Changes    Path
  1.23      +53 -6     jakarta-tomcat-connectors/jk/native2/common/jk_vm_default.c
  
  Index: jk_vm_default.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_vm_default.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- jk_vm_default.c	15 Oct 2002 13:59:49 -0000	1.22
  +++ jk_vm_default.c	24 Oct 2002 15:37:18 -0000	1.23
  @@ -184,6 +184,24 @@
   }
   #endif
   
  +/* JVM hooks */
  +static int jk2_jni_error_signaled = JK_FALSE;
  +static int jk2_jni_error_code = 0;
  +static int jk2_jni_abort_signaled = JK_FALSE;
  +
  +static void jk2_jni_error_hook(int code)
  +{
  +    jk2_jni_error_signaled = JK_TRUE;
  +    jk2_jni_error_code = code;
  +    
  +    fprintf(stderr, "JVM error hook called %d\n", code);
  +}
  +
  +static void jk2_jni_abort_hook()
  +{
  +    jk2_jni_abort_signaled = JK_TRUE;    
  +    fprintf(stderr, "JVM abort hook\n");
  +} 
   
   /** Load the VM. Must be called after init.
    */
  @@ -400,9 +418,33 @@
                                              (char *)p->pstrdup( env, p, *current ) );
   
           if( jvm!=NULL && jk2_file_exists(env, jvm)) {
  +            char *ldlib;
  +            env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                         "jni.guessJvmDll() trying %s\n", jvm);
  +            /* Check if the LD_LIBRARY_PATH points to the discovered jvm.
  +             * XXX only tested on Linux.
  +             */
  +            ldlib = getenv("LD_LIBRARY_PATH");
  +            if (ldlib && strlen(ldlib)) {
  +                char *token;
  +                
  +                token = strtok(ldlib, ":");
  +                while (token != NULL) {
  +                    if (strncmp(token, jvm, strlen(token)) == 0) {
  +                        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                                      "jni.guessJvmDll() found %s in %s.\n", jvm, token);
  +                        return jvm;
  +                    } 
  +                    token = strtok(NULL, ":");                   
  +                }
  +                env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                              "jni.guessJvmDll() could not find %s in the LD_LIBRARY_PATH\n",
  +                              jvm);
  +                return NULL;                                    
  +            }
               env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                          "jni.guessJvmDll() %s\n", jvm);
  -            return jvm;
  +                          "jni.guessJvmDll() LD_LIBRARY_PATH environment var is not set\n");
  +            return NULL;                                
           }
   
           env->l->jkLog(env, env->l, JK_LOG_INFO,
  @@ -485,8 +527,6 @@
           return JK_ERR;
       }
   
  -    vm_args.version = JNI_VERSION_1_2;
  -    vm_args.options = options;
       for (classn = 0; classn < jkvm->nClasspath; classn++)
           classl += strlen(jkvm->classpath[classn]);
       if (classl) {
  @@ -513,9 +553,16 @@
                             "vm.openJvm2() Classpath: %s\n", classpath);
           options[optn++].optionString = classpath;
       }
  -
  -    vm_args.nOptions = optn;
       
  +    /* Set the abort and exit hooks */
  +    options[optn].optionString = "exit";
  +    options[optn++].extraInfo = jk2_jni_error_hook;
  +    options[optn].optionString = "abort";
  +    options[optn++].extraInfo = jk2_jni_abort_hook;
  +    
  +    vm_args.version = JNI_VERSION_1_2;
  +    vm_args.options = options;
  +    vm_args.nOptions = optn;    
       vm_args.ignoreUnrecognized = JNI_TRUE;
   
       err=jni_create_java_vm(&jvm, &penv, &vm_args);
  
  
  

--
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