tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shac...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/native/jk jk_jni_worker.c jk_map.c jk_util.c jk_util.h
Date Mon, 01 May 2000 12:30:33 GMT
shachor     00/05/01 05:30:33

  Modified:    src/native/jk jk_jni_worker.c jk_map.c jk_util.c jk_util.h
  Log:
  First version of the Tomcat/Jakarta NT service
  
  Revision  Changes    Path
  1.2       +26 -39    jakarta-tomcat/src/native/jk/jk_jni_worker.c
  
  Index: jk_jni_worker.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_jni_worker.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_jni_worker.c	2000/04/17 09:47:22	1.1
  +++ jk_jni_worker.c	2000/05/01 12:30:32	1.2
  @@ -57,7 +57,7 @@
    * Description: In process JNI worker                                      *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Based on:                                                               *
  - * Version:     $Revision: 1.1 $                                               *
  + * Version:     $Revision: 1.2 $                                               *
    ***************************************************************************/
   
   #ifndef WIN32
  @@ -76,10 +76,13 @@
   
   #define JAVA_BRIDGE_CLASS_NAME ("org/apache/tomcat/service/JNIEndpoint")
    
  -static int jni_instance_created = JK_FALSE;
  +static jk_worker_t *the_singleton_jni_worker = NULL;
   
   struct jni_worker {
   
  +    int was_verified;
  +    int was_initialized;
  +
       jk_pool_t p;
       jk_pool_atom_t buf[TINY_POOL_SIZE];
       /*
  @@ -170,9 +173,6 @@
   
   static void detach_from_jvm(jni_worker_t *p);
   
  -static void append_libpath(jk_pool_t *p, 
  -                           const char *libpath);
  -  
   static int JK_METHOD service(jk_endpoint_t *e, 
                                jk_ws_service_t *s,
                                jk_logger_t *l,
  @@ -235,6 +235,10 @@
           char *str_config = NULL;
           JNIEnv *env;
   
  +        if(p->was_verified) {
  +            return JK_TRUE;
  +        }
  +
           if(jk_get_worker_mx(props, p->name, &mem_config)) {
               p->tomcat_mx = mem_config;
           }
  @@ -277,7 +281,7 @@
           }
           
           if(jk_get_worker_libpath(props, p->name, &str_config)) {
  -            append_libpath(&p->p, str_config);
  +            jk_append_libpath(&p->p, str_config);
           }
   
   
  @@ -285,6 +289,7 @@
               if(open_jvm(p, &env, l)) {
                   if(get_bridge_object(p, env, l)) {
                       if(get_method_ids(p, env, l)) {
  +                        p->was_verified = JK_TRUE;
                           return JK_TRUE;
                       }
                   }
  @@ -307,6 +312,10 @@
           jni_worker_t *p = pThis->worker_private;
           JNIEnv *env;
   
  +        if(p->was_initialized) {
  +            return JK_TRUE;
  +        }
  +
           if(!p->jvm ||
              !p->jk_java_bridge_object ||
              !p->jk_service_method     ||
  @@ -339,7 +348,12 @@
                                          stderr_name);
   
               detach_from_jvm(p);
  -            return rc == 0 ? JK_FALSE : JK_TRUE;
  +
  +            if(rc) {
  +                p->was_initialized = JK_TRUE; 
  +                return JK_TRUE;
  +            }
  +            return JK_FALSE;
           }
       }
       return JK_FALSE;
  @@ -409,9 +423,9 @@
   {
   
       if(NULL != name && NULL != w) {
  -        if(jni_instance_created) {
  -            *w = NULL;
  -            return JK_FALSE;
  +        if(the_singleton_jni_worker) {
  +            *w = the_singleton_jni_worker;
  +            return JK_TRUE;
           } else {
               jni_worker_t *private_data = 
                   (jni_worker_t *)malloc(sizeof(jni_worker_t ));
  @@ -425,6 +439,8 @@
                   private_data->name = jk_pool_strdup(&private_data->p, name);
         
   
                   if(private_data->name) {
  +                    private_data->was_verified          = JK_FALSE;
  +                    private_data->was_initialized       = JK_FALSE;
                       private_data->jvm                   = NULL; 
                       private_data->jk_java_bridge_object = NULL;
                       private_data->jk_java_bridge_class  = NULL;
  @@ -447,6 +463,7 @@
                       private_data->worker.destroy        = destroy;
   
                       *w = &private_data->worker;
  +                    the_singleton_jni_worker = &private_data->worker; 
                       return JK_TRUE;
                   }
   
  @@ -624,34 +641,4 @@
   static void detach_from_jvm(jni_worker_t *p)
   {
       (*(p->jvm))->DetachCurrentThread(p->jvm);
  -}
  -
  -static void append_libpath(jk_pool_t *p, 
  -                           const char *libpath)
  -{
  -    char *env = NULL;
  -    char *current = getenv(PATH_ENV_VARIABLE);
  -
  -    if(current) {
  -        env = jk_pool_alloc(p, strlen(PATH_ENV_VARIABLE) + 
  -                               strlen(current) + 
  -                               strlen(libpath) + 5);
  -        if(env) {
  -            sprintf(env, "%s=%s%c%s", 
  -                    PATH_ENV_VARIABLE, 
  -                    libpath, 
  -                    PATH_SEPERATOR, 
  -                    current);
  -        }
  -    } else {
  -        env = jk_pool_alloc(p, strlen(PATH_ENV_VARIABLE) +                            
  
  -                               strlen(libpath) + 5);
  -        if(env) {
  -            sprintf(env, "%s=%s", PATH_ENV_VARIABLE, libpath);
  -        }
  -    }
  -
  -    if(env) {
  -        putenv(env);
  -    }
   }
  
  
  
  1.2       +42 -1     jakarta-tomcat/src/native/jk/jk_map.c
  
  Index: jk_map.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_map.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_map.c	2000/04/17 09:47:22	1.1
  +++ jk_map.c	2000/05/01 12:30:32	1.2
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: General purpose map object                                 *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.1 $                                               *
  + * Version:     $Revision: 1.2 $                                               *
    ***************************************************************************/
   
   #include "jk_global.h"
  @@ -82,6 +82,7 @@
   static void trim_prp_comment(char *prp);
   static int trim(char *s);
   static int map_realloc(jk_map_t *m);
  +static char *update_env_variables(char *value, jk_map_t *m);
   
   int map_alloc(jk_map_t **m)
   {
  @@ -288,7 +289,7 @@
           FILE *fp = fopen(f, "r");
           
           if(fp) {
  -            char buf[LENGTH_OF_LINE + 1];
  +            char buf[LENGTH_OF_LINE + 1];            
               char *prp;
               
               rc = JK_TRUE;
  @@ -302,6 +303,7 @@
                           v++;                        
                           if(strlen(v) && strlen(prp)) {
                               char *oldv = map_get_string(m, prp, NULL);
  +                            v = update_env_variables(v, m);
                               if(oldv) {
                                   char *tmpv = jk_pool_alloc(&m->p, 
                                                              strlen(v) + strlen(oldv) + 3);
  @@ -420,3 +422,42 @@
   
       return JK_FALSE;
   }
  +
  +static char *update_env_variables(char *value, jk_map_t *m)
  +{
  +    char *rc = value;
  +    char *env_start = value;
  +
  +    while(env_start = strstr(env_start, "$(")) {
  +        char *env_end = strstr(env_start, ")");
  +        if(env_end) {
  +            char env_name[LENGTH_OF_LINE + 1] = ""; 
  +            char *env_value;
  +
  +            *env_end = '\0';
  +            strcpy(env_name, env_start + 2);
  +            *env_end = ')';
  +
  +            env_value = map_get_string(m, env_name, NULL);
  +            if(env_value) {
  +                char *new_value = jk_pool_alloc(&m->p, 
  +                                                (sizeof(char) * (strlen(rc) + strlen(env_value))));
  +                if(!new_value) {
  +                    break;
  +                }
  +                *env_start = '\0';
  +                strcpy(new_value, rc);
  +                strcat(new_value, env_value);
  +                strcat(new_value, env_end + 1);
  +                rc = new_value;
  +                env_start = rc;
  +            } else {
  +                env_start = env_end;
  +            }
  +        } else {
  +            break;
  +        }
  +    }
  +
  +    return rc;
  +}
  \ No newline at end of file
  
  
  
  1.2       +30 -0     jakarta-tomcat/src/native/jk/jk_util.c
  
  Index: jk_util.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_util.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_util.c	2000/04/17 09:47:21	1.1
  +++ jk_util.c	2000/05/01 12:30:32	1.2
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Utility functions (mainly configuration)                   *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.1 $                                               *
  + * Version:     $Revision: 1.2 $                                               *
    ***************************************************************************/
   
   
  @@ -567,3 +567,33 @@
   
       return rc;
   }
  +
  +void jk_append_libpath(jk_pool_t *p, 
  +                       const char *libpath)
  +{
  +    char *env = NULL;
  +    char *current = getenv(PATH_ENV_VARIABLE);
  +
  +    if(current) {
  +        env = jk_pool_alloc(p, strlen(PATH_ENV_VARIABLE) + 
  +                               strlen(current) + 
  +                               strlen(libpath) + 5);
  +        if(env) {
  +            sprintf(env, "%s=%s%c%s", 
  +                    PATH_ENV_VARIABLE, 
  +                    libpath, 
  +                    PATH_SEPERATOR, 
  +                    current);
  +        }
  +    } else {
  +        env = jk_pool_alloc(p, strlen(PATH_ENV_VARIABLE) +                            
  
  +                               strlen(libpath) + 5);
  +        if(env) {
  +            sprintf(env, "%s=%s", PATH_ENV_VARIABLE, libpath);
  +        }
  +    }
  +
  +    if(env) {
  +        putenv(env);
  +    }
  +}
  \ No newline at end of file
  
  
  
  1.2       +3 -0      jakarta-tomcat/src/native/jk/jk_util.h
  
  Index: jk_util.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_util.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_util.h	2000/04/17 09:47:21	1.1
  +++ jk_util.h	2000/05/01 12:30:32	1.2
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Various utility functions                                  *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.1 $                                               *
  + * Version:     $Revision: 1.2 $                                               *
    ***************************************************************************/
   #ifndef _JK_UTIL_H
   #define _JK_UTIL_H
  @@ -155,6 +155,9 @@
   char **jk_parse_sysprops(jk_pool_t *p, 
                            const char *sysprops);
           
  +
  +void jk_append_libpath(jk_pool_t *p, 
  +                       const char *libpath);
   
   #ifdef __cplusplus
   extern "C" {
  
  
  

Mime
View raw message