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/server/isapi jk_isapi_plugin.c
Date Fri, 07 Jun 2002 23:45:30 GMT
costin      2002/06/07 16:45:30

  Modified:    jk/native2/common jk_logger_file.c
               jk/native2/server/apache13 mod_jk2.c
               jk/native2/server/apache2 jk_logger_apache2.c mod_jk2.c
               jk/native2/server/isapi jk_isapi_plugin.c
  Log:
  If APR is available, use it to avoid some ugly vprintf/buf ugliness.
  
  Use APR pools if apr is available - there is no point in using the old
  jk pools if we use APR. Right now the only use of the jk_pool remains
  apache1.3 when built without APR ( to get around some aledged problems
  when the binary version of apr won't work with single-threaded apache ).
  
  This is also supposed to resolve the crash reported by JFC.
  
  Revision  Changes    Path
  1.24      +47 -1     jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c
  
  Index: jk_logger_file.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- jk_logger_file.c	28 May 2002 22:44:50 -0000	1.23
  +++ jk_logger_file.c	7 Jun 2002 23:45:30 -0000	1.24
  @@ -59,7 +59,7 @@
    * Description: Utility functions (mainly configuration)                   *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.23 $                                           *
  + * Version:     $Revision: 1.24 $                                           *
    ***************************************************************************/
   
   #include "jk_env.h"
  @@ -210,6 +210,51 @@
   	return JK_OK;
   }
   
  +#ifdef HAS_APR
  +
  +static int JK_METHOD jk2_logger_file_jkVLog(jk_env_t *env, jk_logger_t *l,
  +                                  const char *file,
  +                                  int line,
  +                                  int level,
  +                                  const char *fmt,
  +                                  va_list args)
  +{
  +    int rc = 0;
  +    char *buf;
  +    char *fmt1;
  +    apr_pool_t *aprPool=env->tmpPool->_private;
  +    char rfctime[APR_RFC822_DATE_LEN];
  +    apr_time_t time = apr_time_now();
  +    
  +    if( !file || !args) {
  +        return -1;
  +    }
  +
  +    if(l->logger_private==NULL ||
  +       l->level <= level) {
  +        char *f = (char *)(file + strlen(file) - 1);
  +
  +        while(f != file && '\\' != *f && '/' != *f) {
  +            f--;
  +        }
  +        if(f != file) {
  +            f++;
  +        }
  +        
  +        /* XXX or apr_ctime ? */
  +        apr_rfc822_date( rfctime, time );
  +        fmt1=apr_pvsprintf( aprPool, "[%s] [%s:%d] %s", rfctime, file, line, fmt );
  +        buf=apr_pvsprintf( aprPool, fmt, args );
  +
  +        l->log(env, l, level, buf);
  +        
  +    }
  +    
  +    return rc;
  +}
  +
  +
  +#else
   
   static int JK_METHOD jk2_logger_file_jkVLog(jk_env_t *env, jk_logger_t *l,
                                     const char *file,
  @@ -284,6 +329,7 @@
       return rc;
   }
   
  +#endif
   
   
   static int jk2_logger_file_jkLog(jk_env_t *env, jk_logger_t *l,
  
  
  
  1.15      +12 -2     jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- mod_jk2.c	24 May 2002 07:12:32 -0000	1.14
  +++ mod_jk2.c	7 Jun 2002 23:45:30 -0000	1.15
  @@ -59,7 +59,7 @@
    * Description: Apache 1.3 plugin for Jakarta/Tomcat                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    *                 Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.14 $                                           *
  + * Version:     $Revision: 1.15 $                                           *
    ***************************************************************************/
   
   /*
  @@ -130,6 +130,10 @@
       return NULL;
   }
   
  +#ifdef HAS_APR
  +apr_pool_t *jk_globalPool;
  +#endif
  +
   /* Create the initial set of objects. You need to cut&paste this and
      adapt to your server.
    */
  @@ -139,11 +143,17 @@
       jk_pool_t *globalPool;
       jk_bean_t *jkb;
   
  +#ifdef HAS_APR
  +    apr_pool_create( &jk_globalPool, NULL );
  +
  +    jk2_pool_apr_create( NULL, &globalPool, NULL, jk_globalPool );
  +#else
       /** First create a pool. We use the default ( jk ) pool impl,
        *  other choices are apr or native.
        */
       jk2_pool_create( NULL, &globalPool, NULL, 2048 );
  -
  +#endif
  +    
       /** Create the global environment. This will register the default
           factories, to be overriten later.
       */
  
  
  
  1.25      +8 -18     jakarta-tomcat-connectors/jk/native2/server/apache2/jk_logger_apache2.c
  
  Index: jk_logger_apache2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/jk_logger_apache2.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- jk_logger_apache2.c	5 Jun 2002 19:25:39 -0000	1.24
  +++ jk_logger_apache2.c	7 Jun 2002 23:45:30 -0000	1.25
  @@ -108,17 +108,16 @@
   {
       /* XXX map jk level to apache level */
       server_rec *s=(server_rec *)l->logger_private;
  +    /* If we use apache2 logger, we should also use APR pools.
  +       It is possible to do some workarounds, but it would be stupid, especially
  +       since the idea is to use apr pools long term, with the old jk_pool as
  +       a workaround for apache13 and where apr is not available */
  +    apr_pool_t *aprPool=env->tmpPool->_private;
       int rc;
  +    char *buf;
   
       /* XXX XXX Change this to "SMALLSTACK" or something, I don't think it's
          netware specific */
  -#ifdef NETWARE
  -/* On NetWare, this can get called on a thread that has a limited stack so */
  -/* we will allocate and free the temporary buffer in this function         */
  -    char *buf;
  -#else
  -    char buf[HUGE_BUFFER_SIZE];
  -#endif
   
       if( level < l->level )
           return JK_OK;
  @@ -126,15 +125,9 @@
       if( s==NULL ) {
           return JK_ERR;
       }
  +
  +    buf=apr_pvsprintf( aprPool, fmt, args );
       
  -#if defined(NETWARE) /* until we get a vsnprintf function */
  -    /* XXX Can we use a pool ? */
  -    /* XXX It'll go away with env and per thread data !! */
  -    buf = (char *) malloc(HUGE_BUFFER_SIZE);
  -    rc = vsprintf(buf, fmt, args);
  -#else 
  -    rc = vsnprintf(buf, HUGE_BUFFER_SIZE, fmt, args);
  -#endif
       rc=strlen( buf );
       /* Remove trailing \n. XXX need to change the log() to not include \n */
       if( buf[rc-1] == '\n' )
  @@ -148,9 +141,6 @@
           ap_log_error( file, line, APLOG_ERR | APLOG_NOERRNO, 0, s, buf);
       }
   
  -#ifdef NETWARE
  -    free(buf);
  -#endif
       return rc ;
   }
   
  
  
  
  1.34      +1 -7      jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- mod_jk2.c	5 Jun 2002 19:25:39 -0000	1.33
  +++ mod_jk2.c	7 Jun 2002 23:45:30 -0000	1.34
  @@ -59,7 +59,7 @@
    * Description: Apache 2 plugin for Jakarta/Tomcat                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    *                 Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.33 $                                           *
  + * Version:     $Revision: 1.34 $                                           *
    ***************************************************************************/
   
   /*
  @@ -259,13 +259,7 @@
       jk_pool_t *globalPool;
       jk_bean_t *jkb;
       
  -    /** First create a pool. Compile time option
  -     */
  -#ifdef NO_APACHE_POOL
  -    jk2_pool_create( NULL, &globalPool, NULL, 2048 );
  -#else
       jk2_pool_apr_create( NULL, &globalPool, NULL, p );
  -#endif
   
       /** Create the global environment. This will register the default
           factories
  
  
  
  1.26      +6 -6      jakarta-tomcat-connectors/jk/native2/server/isapi/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/isapi/jk_isapi_plugin.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- jk_isapi_plugin.c	5 Jun 2002 21:40:09 -0000	1.25
  +++ jk_isapi_plugin.c	7 Jun 2002 23:45:30 -0000	1.26
  @@ -60,7 +60,7 @@
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Author:      Larry Isaacs <larryi@apache.org>                           *
    * Author:      Ignacio J. Ortega <nacho@apache.org>                       *
  - * Version:     $Revision: 1.25 $                                           *
  + * Version:     $Revision: 1.26 $                                           *
    ***************************************************************************/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -698,21 +698,21 @@
       return JK_TRUE;     
   }
   
  +apr_pool_t *jk_globalPool;
   
   
   /** Basic initialization for jk2.
    */
  -
  -
   static  jk_env_t*  jk2_create_workerEnv (void) {
   
       jk_logger_t *l;
       jk_pool_t *globalPool;
       jk_bean_t *jkb;
       jk_env_t *env;
  -    /** First create a pool. Compile time option
  -     */
  -    jk2_pool_create( NULL, &globalPool, NULL, 2048 );
  +    
  +    apr_pool_create( &jk_globalPool, NULL );
  +
  +    jk2_pool_apr_create( NULL, &globalPool, NULL, jk_globalPool );
   
       /** Create the global environment. This will register the default
           factories
  
  
  

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