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/apache2 jk_apache2.h jk_service_apache2.c mod_jk2.c
Date Fri, 31 May 2002 18:29:48 GMT
costin      2002/05/31 11:29:48

  Modified:    jk/native2/server/apache2 jk_apache2.h jk_service_apache2.c
                        mod_jk2.c
  Log:
  Get rid of stack allocated request. It may be faster, but it's hard to debug
  and may create all kind of problems on different platforms.
  
  Eventually the request will be recycled ( we alloc in the endopoint pool,
  which is recycled - the overhead is quite small anyway ).
  
  Revision  Changes    Path
  1.9       +2 -2      jakarta-tomcat-connectors/jk/native2/server/apache2/jk_apache2.h
  
  Index: jk_apache2.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/jk_apache2.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- jk_apache2.h	22 May 2002 23:42:32 -0000	1.8
  +++ jk_apache2.h	31 May 2002 18:29:48 -0000	1.9
  @@ -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.8 $                                           
  + * Version:     $Revision: 1.9 $                                           
    */
   
   #include "jk_global.h"
  @@ -73,7 +73,7 @@
   #include "jk_requtil.h"
   
   
  -int jk2_service_apache2_init(jk_env_t *env, jk_ws_service_t *s);
  +int JK_METHOD jk2_service_apache2_init(jk_env_t *env, jk_ws_service_t *s);
   
   int JK_METHOD jk2_logger_apache2_factory(jk_env_t *env, jk_pool_t *pool,
                                            jk_bean_t *result, const char *type, const char
*name);
  
  
  
  1.24      +37 -24    jakarta-tomcat-connectors/jk/native2/server/apache2/jk_service_apache2.c
  
  Index: jk_service_apache2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/jk_service_apache2.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- jk_service_apache2.c	18 May 2002 22:45:04 -0000	1.23
  +++ jk_service_apache2.c	31 May 2002 18:29:48 -0000	1.24
  @@ -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.23 $                                           
  + * Version:     $Revision: 1.24 $                                           
    */
   
   #include "apu_compat.h"
  @@ -96,7 +96,7 @@
   
   /* #define USE_APRTABLES  */
   
  -#define NULL_FOR_EMPTY(x)   ((x && !strlen(x)) ? NULL : x) 
  +#define NULL_FOR_EMPTY(x)   ((((x)!=NULL) && (strlen((x))!=0)) ? (x) : NULL ) 
   
   static int JK_METHOD jk2_service_apache2_head(jk_env_t *env, jk_ws_service_t *s )
   {
  @@ -106,8 +106,11 @@
       jk_map_t *headers;
       int debug=1;
       
  -    if(s==NULL ||  s->ws_private==NULL )
  +    if(s==NULL ||  s->ws_private==NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +                      "service.head() NullPointerException\n");
           return JK_ERR;
  +    }
       
       if( s->uriEnv != NULL )
           debug=s->uriEnv->mbean->debug;
  @@ -211,24 +214,27 @@
                                                 void *b, unsigned len,
                                                 unsigned *actually_read)
   {
  -    if(s && s->ws_private && b && actually_read) {
  -        if(!s->read_body_started) {
  -           if(ap_should_client_block(s->ws_private)) {
  -                s->read_body_started = JK_TRUE;
  -            }
  +    if(s==NULL || s->ws_private==NULL ||  b==NULL || actually_read==NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +                      "service.read() NullPointerException\n");
  +        return JK_ERR;
  +    }
  +
  +    if(!s->read_body_started) {
  +        if(ap_should_client_block(s->ws_private)) {
  +            s->read_body_started = JK_TRUE;
           }
  +    }
   
  -        if(s->read_body_started) {
  -            long rv;
  -            if ((rv = ap_get_client_block(s->ws_private, b, len)) < 0) {
  -                *actually_read = 0;
  -            } else {
  -                *actually_read = (unsigned) rv;
  -            }
  -            return JK_OK;
  +    if(s->read_body_started) {
  +        long rv;
  +        if ((rv = ap_get_client_block(s->ws_private, b, len)) < 0) {
  +            *actually_read = 0;
  +        } else {
  +            *actually_read = (unsigned) rv;
           }
       }
  -    return JK_ERR;
  +    return JK_OK;
   }
   
   /*
  @@ -255,8 +261,11 @@
       char *bb=(char *)b;
       request_rec *rr;
       int debug=1;
  +    int rc;
       
       if(s==NULL  || s->ws_private == NULL ||  b==NULL) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +                      "service.write() NullPointerException\n");
           return JK_ERR;
       }
       if( s->uriEnv != NULL )
  @@ -274,8 +283,9 @@
           if( debug > 0 )
               env->l->jkLog(env, env->l, JK_LOG_INFO, 
                             "service.write() default head\n");
  -        if(s->head(env, s) != JK_OK) {
  -            return JK_ERR;
  +        rc=s->head(env, s);
  +        if( rc != JK_OK) {
  +            return rc;
           }
           
           {
  @@ -306,7 +316,7 @@
           
           if(toSend != r) { 
               return JK_ERR; 
  -                } 
  +        } 
           
       }
       
  @@ -345,14 +355,15 @@
   }
   
   static int JK_METHOD jk2_init_ws_service(jk_env_t *env, jk_ws_service_t *s,
  -                               jk_worker_t *worker, void *serverObj)
  +                                         jk_worker_t *worker, void *serverObj)
   {
       apr_port_t port;
       char *ssl_temp      = NULL;
  -    jk_workerEnv_t *workerEnv=worker->workerEnv;
  +    jk_workerEnv_t *workerEnv;
       request_rec *r=serverObj;
       int need_content_length_header=JK_FALSE;
   
  +    workerEnv = worker->workerEnv;
       /* Common initialization */
       /* XXX Probably not needed, we're duplicating */
       jk2_requtil_initRequest(env, s);
  @@ -600,9 +611,11 @@
       }
   }
   
  -int jk2_service_apache2_init(jk_env_t *env, jk_ws_service_t *s)
  +int JK_METHOD jk2_service_apache2_init(jk_env_t *env, jk_ws_service_t *s)
   {
       if(s==NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +                      "service.init() NullPointerException\n");
           return JK_ERR;
       }
   
  @@ -611,6 +624,6 @@
       s->write  = jk2_service_apache2_write;
       s->init   = jk2_init_ws_service;
       s->afterRequest     = jk2_service_apache2_afterRequest;
  -    
  +
       return JK_OK;
   }
  
  
  
  1.29      +62 -53    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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- mod_jk2.c	29 May 2002 17:51:23 -0000	1.28
  +++ mod_jk2.c	31 May 2002 18:29:48 -0000	1.29
  @@ -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.28 $                                           *
  + * Version:     $Revision: 1.29 $                                           *
    ***************************************************************************/
   
   /*
  @@ -194,10 +194,10 @@
   
       uriEnv->mbean->setAttribute( workerEnv->globalEnv, uriEnv->mbean, (char
*)name, (void *)val );
       
  -    fprintf(stderr, "JkUriSet  %s %s dir=%s args=%s\n",
  -            uriEnv->workerName, cmd->path,
  -            cmd->directive->directive,
  -            cmd->directive->args);
  +/*     fprintf(stderr, "JkUriSet  %s %s dir=%s args=%s\n", */
  +/*             uriEnv->workerName, cmd->path, */
  +/*             cmd->directive->directive, */
  +/*             cmd->directive->args); */
   
       return NULL;
   }
  @@ -305,6 +305,7 @@
       /* Create the workerEnv */
       jkb=env->createBean2( env, env->globalPool,"workerEnv", "");
       workerEnv= jkb->object;
  +/*     workerEnv->logger_name= "logger.apache2"; */
       env->alias( env, "workerEnv:" , "workerEnv");
       
       if( workerEnv==NULL ) {
  @@ -445,7 +446,6 @@
       rc=jk2_apache2_isValidating( plog, &gPool );
   
       env->setAprPool(env, gPool);
  -    fprintf( stderr, "XXX Gpool %p\n", gPool );
       
       if( rc == JK_OK && gPool != NULL ) {
           /* This is the first step */
  @@ -488,9 +488,10 @@
           workerEnv->was_initialized = JK_TRUE;        
           
           jk2_init( env, pconf, workerEnv, s );
  -    
  -        env->l->jkLog(env, env->l, JK_LOG_INFO, "mod_jk child init %d %d\n",
  -                      workerEnv->was_initialized, workerEnv->childId );
  +
  +        if( workerEnv->childId <= 0 ) 
  +            env->l->jkLog(env, env->l, JK_LOG_INFO, "mod_jk child init %d %d\n",
  +                          workerEnv->was_initialized, workerEnv->childId );
       }
       
   }
  @@ -512,6 +513,10 @@
       jk_env_t *env;
       jk_workerEnv_t *workerEnv;
   
  +    jk_ws_service_t *s=NULL;
  +    jk_pool_t *rPool=NULL;
  +    int rc1;
  +
       uriEnv=ap_get_module_config( r->request_config, &jk2_module );
   
       /* not for me, try next handler */
  @@ -548,13 +553,13 @@
           if( worker==NULL && uriEnv->workerName != NULL ) {
               worker=env->getByName( env, uriEnv->workerName);
               env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                          "mod_jk.handler() finding worker for %p %p\n",
  -                          worker, uriEnv );
  +                          "mod_jk.handler() finding worker for %p %p %s\n",
  +                          worker, uriEnv, uriEnv->workerName);
               uriEnv->worker=worker;
           }
       }
   
  -    if(worker==NULL ) {
  +    if(worker==NULL || worker->mbean == NULL || worker->mbean->localName==NULL
) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR, 
                         "mod_jk.handle() No worker for %s\n", r->uri); 
           workerEnv->globalEnv->releaseEnv( workerEnv->globalEnv, env );
  @@ -563,49 +568,53 @@
   
       if( uriEnv->mbean->debug > 0 )
           env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                      "mod_jk.handler() serving %s with %s\n",
  -                      uriEnv->mbean->localName, worker->mbean->localName );
  -    {
  -        jk_ws_service_t sOnStack;
  -        jk_ws_service_t *s=&sOnStack;
  -        jk_pool_t *rPool=NULL;
  -        int rc1;
  -
  -        /* Get a pool for the request XXX move it in workerEnv to
  -           be shared with other server adapters */
  -        rPool= worker->rPoolCache->get( env, worker->rPoolCache );
  -        if( rPool == NULL ) {
  -            rPool=worker->mbean->pool->create( env, worker->mbean->pool,
HUGE_POOL_SIZE );
  -            if( uriEnv->mbean->debug > 0 )
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                              "mod_jk.handler(): new rpool %p\n", rPool );
  -        }
  -
  -        /* XXX we should reuse the request itself !!! */
  -        jk2_service_apache2_init( env, s );
  +                      "mod_jk.handler() serving %s with %p %p %s\n",
  +                      uriEnv->mbean->localName, worker, worker->mbean, worker->mbean->localName
);
   
  -        s->pool = rPool;
  -        s->init( env, s, worker, r );
  +    fprintf( stderr, "XXX 1 %p %p\n", worker, worker->rPoolCache );
   
  -        s->is_recoverable_error = JK_FALSE;
  -        s->uriEnv = uriEnv; 
  +    /* Get a pool for the request XXX move it in workerEnv to
  +       be shared with other server adapters */
  +    rPool= worker->rPoolCache->get( env, worker->rPoolCache );
  +    if( rPool == NULL ) {
  +        rPool=worker->mbean->pool->create( env, worker->mbean->pool, HUGE_POOL_SIZE
);
  +        if( uriEnv->mbean->debug > 0 )
  +            env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                          "mod_jk.handler(): new rpool %p\n", rPool );
  +    }
  +    
  +    fprintf( stderr, "XXX 2 %p\n", worker );
  +    
  +    s=(jk_ws_service_t *)rPool->calloc( env, rPool, sizeof( jk_ws_service_t ));
  +    
  +    fprintf( stderr, "XXX 2 %p\n", s );
   
  -        /* env->l->jkLog(env, env->l, JK_LOG_INFO,  */
  -        /*              "mod_jk.handler() Calling %s\n", worker->mbean->name); */
  -        
  -        rc = worker->service(env, worker, s);
  +    /* XXX we should reuse the request itself !!! */
  +    jk2_service_apache2_init( env, s );
  +    
  +    fprintf( stderr, "XXX 3 %p %p\n", s, worker );
   
  -        s->afterRequest(env, s);
  +    s->pool = rPool;
  +    s->init( env, s, worker, r );
  +    
  +    s->is_recoverable_error = JK_FALSE;
  +    s->uriEnv = uriEnv; 
   
  -        rPool->reset(env, rPool);
  -        
  -        rc1=worker->rPoolCache->put( env, worker->rPoolCache, rPool );
  -        if( rc1 == JK_OK ) {
  -            rPool=NULL;
  -        }
  -        if( rPool!=NULL ) {
  -            rPool->close(env, rPool);
  -        }
  +    /* env->l->jkLog(env, env->l, JK_LOG_INFO,  */
  +    /*              "mod_jk.handler() Calling %s\n", worker->mbean->name); */
  +    
  +    rc = worker->service(env, worker, s);
  +    
  +    s->afterRequest(env, s);
  +    
  +    rPool->reset(env, rPool);
  +    
  +    rc1=worker->rPoolCache->put( env, worker->rPoolCache, rPool );
  +    if( rc1 == JK_OK ) {
  +        rPool=NULL;
  +    }
  +    if( rPool!=NULL ) {
  +        rPool->close(env, rPool);
       }
   
       if(rc==JK_OK) {
  @@ -679,8 +688,8 @@
   
       if( uriEnv->mbean->debug > 0 )
           env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                      "mod_jk.translate(): uriMap %s %s\n",
  -                      r->uri, uriEnv->workerName);
  +                      "mod_jk.translate(): uriMap %s %s %p\n",
  +                      r->uri, uriEnv->workerName, uriEnv->worker);
   
       workerEnv->globalEnv->releaseEnv( workerEnv->globalEnv, env );
       return OK;
  @@ -736,4 +745,4 @@
   }
   
   
  -#endif
  \ No newline at end of file
  +#endif
  
  
  

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