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_worker_ajp13.c
Date Sat, 11 May 2002 00:06:58 GMT
costin      02/05/10 17:06:58

  Modified:    jk/native2/common jk_worker_ajp13.c
  Log:
  Few ( bigger ) changes:
  
  - we no longer de-allocate the endpoint. The ep will store important statistics
  about request processing ( times, nr. of requests, etc ) - it's much better
  than the worker since an endpoint is active in a single thread, so we
  don't need atomic or syncs.
  
  - also check if we are connected ( right now we use sd, if it's <0 we
  assume it's not connected - we set it to -1 when we create the endpoint
  and after close, and set it to 0 if the channel doesn't do it - I could
  add a separate flag but I'm lazy today ).
  
  - few small fixes to make sure the endpoints are doing well.
  
  Revision  Changes    Path
  1.18      +75 -55    jakarta-tomcat-connectors/jk/native2/common/jk_worker_ajp13.c
  
  Index: jk_worker_ajp13.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_ajp13.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jk_worker_ajp13.c	9 May 2002 23:47:31 -0000	1.17
  +++ jk_worker_ajp13.c	11 May 2002 00:06:58 -0000	1.18
  @@ -166,8 +166,6 @@
           ajp14->route=value;
       } else if( strcmp( name, "group" )==0 ) {
           ajp14->groups->add( env, ajp14->groups, value, ajp14 );
  -    } else if( strcmp( name, "cachesize" )==0 ) {
  -        ajp14->cache_sz=atoi( value );
       } else if( strcmp( name, "lb_factor" )==0 ) {
           ajp14->lb_factor=atoi( value );
       } else if( strcmp( name, "channel" )==0 ) {
  @@ -220,10 +218,14 @@
       ae->reuse = JK_FALSE;
       if( ae->worker->channel != NULL )
           ae->worker->channel->close( env, ae->worker->channel, ae );
  +    
       ae->cPool->reset( env, ae->cPool );
  -    ae->cPool->close( env, ae->cPool );
  -    ae->pool->reset( env, ae->pool );
  -    ae->pool->close( env, ae->pool );
  +    /* ae->cPool->close( env, ae->cPool ); */
  +
  +    /* Don't touch the ae->pool, the object has important
  +       statistics */
  +    /* ae->pool->reset( env, ae->pool ); */
  +    /*     ae->pool->close( env, ae->pool ); */
   }
   
   /** Connect a channel, implementing the logging protocol if ajp14
  @@ -252,6 +254,13 @@
           return JK_ERR;
       }
   
  +    /* We just reconnected, reset error state
  +     */
  +    ae->worker->in_error_state=0;
  +    
  +    /** XXX use a 'connected' field */
  +    if( ae->sd == -1 ) ae->sd=0;
  +    
       /* Check if we must execute a logon after the physical connect */
       if (ae->worker->secret == NULL)
           return JK_OK;
  @@ -294,7 +303,7 @@
                                 jk_endpoint_t   *e )
   {
       int attempt;
  -    int err;
  +    int err=JK_OK;
       
       /*
        * Try to send the request on a valid endpoint. If one endpoint
  @@ -306,11 +315,20 @@
       for(attempt = 0 ; attempt < JK_RETRIES ;attempt++) {
           jk_channel_t *channel= worker->channel;
   
  +        if( e->sd == -1 ) {
  +            err=jk2_worker_ajp14_connect(env, e);
  +            if( err!=JK_OK ) {
  +                env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                              "ajp14.service() failed to connect endpoint errno=%d %s\n",
  +                              errno, strerror( errno ));
  +                return err;
  +            }
  +        }
           /* e->request->dump(env, e->request, "Before sending "); */
           err=e->worker->channel->send( env, e->worker->channel, e,
                                         e->request );
  -
  -	    if (err==JK_OK ) {
  +        e->request->dump( env, e->request, "Sent" );
  +        if (err==JK_OK ) {
               /* We sent the request, have valid endpoint */
               break;
           }
  @@ -323,11 +341,10 @@
           }
           
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                "ajp14.service() error sending, reconnect %s %s\n",
  -                      e->worker->mbean->name, e->worker->channelName);
  +                      "ajp14.service() error sending, reconnect %s %d %d %s\n",
  +                      e->worker->channelName, err, errno, strerror(errno));
   
           channel->close( env, channel, e );
  -
           err=jk2_worker_ajp14_connect(env, e); 
   
           if( err != JK_OK ) {
  @@ -386,10 +403,6 @@
                                          e->post );
       }
   
  -    if( e->worker->mbean->debug > 0 )
  -        env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "ajp14.service() processing callbacks %s\n", e->worker->channel->mbean->name);
  -
       err = e->worker->workerEnv->processCallbacks(env, e->worker->workerEnv,
                                                    e, s);
       
  @@ -515,31 +528,35 @@
   jk2_worker_ajp14_done(jk_env_t *env, jk_worker_t *we, jk_endpoint_t *e)
   {
       jk_worker_t *w;
  +    int rc=JK_OK;
       
       w= e->worker;
       
       if( e->cPool != NULL ) 
           e->cPool->reset(env, e->cPool);
  -    if (! w->in_error_state && w->endpointCache != NULL ) {
  -        int err=0;
  -        err=w->endpointCache->put( env, w->endpointCache, e );
  -        if( err==JK_OK ) {
  -            if( w->mbean->debug > 0 ) 
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                              "ajp14.done() return to pool %s\n",
  -                              w->mbean->name );
  -            return JK_OK;
  -        }
  -    }
   
  -    /* No reuse or put() failed */
  -
  -    jk2_close_endpoint(env, e);
  +    if( w->endpointCache == NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, "ajp14.done() No pool\n");
  +        return JK_ERR;
  +    }
  +    
  +    if ( w->in_error_state ) {
  +        jk2_close_endpoint(env, e);
  +        /*     if( w->mbean->debug > 0 )  */
  +        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                      "ajp14.done() close endpoint %s error_state %d\n",
  +                      w->mbean->name, w->in_error_state );
  +    }
  +        
  +    rc=w->endpointCache->put( env, w->endpointCache, e );
  +    if( rc!=JK_OK ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, "ajp14.done() Error recycling
ep\n");
  +        return rc;        
  +    }
       if( w->mbean->debug > 0 ) 
           env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "ajp14.done() close endpoint %s\n",
  +                      "ajp14.done() return to pool %s\n",
                         w->mbean->name );
  -    
       return JK_OK;
   }
   
  @@ -555,25 +572,29 @@
       if( ajp14->secret ==NULL ) {
       }
   
  -    if (ajp14->endpointCache != NULL ) {
  +    if( ajp14->endpointCache == NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, "ajp14.getEndpoint() No pool\n");
  +        return JK_ERR;
  +    }
   
  -        e=ajp14->endpointCache->get( env, ajp14->endpointCache );
  +    e=ajp14->endpointCache->get( env, ajp14->endpointCache );
   
  -        if (e!=NULL) {
  -            if( e->worker->mbean->debug > 0 )
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                              "ajp14.getEndpoint(): Reusing endpoint %s %s\n",
  -                              e->mbean->name, e->worker->mbean->name);
  -            *eP = e;
  -            return JK_OK;
  -        }
  +    if (e!=NULL) {
  +        *eP = e;
  +        return JK_OK;
       }
   
       jkb=env->createBean2( env,ajp14->pool,  "endpoint", NULL );
       if( jkb==NULL )
           return JK_ERR;
  +    if( ajp14->mbean->debug > 0 )
  +        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                      "ajp14.getEndpoint(): Creating endpoint %s %s \n",
  +                      ajp14->mbean->name, jkb->name);
  +    
       e = (jk_endpoint_t *)jkb->object;
       e->worker = ajp14;
  +    e->sd=-1;
   
       *eP = e;
       return JK_OK;
  @@ -617,21 +638,20 @@
          ajp14->channel->mbean->disabled  )
           ajp14->mbean->disabled = JK_TRUE;
       
  -    if( ajp14->cache_sz == -1 )
  -        ajp14->cache_sz=JK_OBJCACHE_DEFAULT_SZ;
  -
  -    if (ajp14->cache_sz > 0) {
  -        ajp14->endpointCache=jk2_objCache_create( env, ajp14->pool  );
  +    ajp14->endpointCache=jk2_objCache_create( env, ajp14->pool  );
           
  -        if( ajp14->endpointCache != NULL ) {
  -            rc=ajp14->endpointCache->init( env, ajp14->endpointCache,
  -                                           ajp14->cache_sz );
  -            if( rc!= JK_OK ) {
  -                ajp14->endpointCache=NULL;
  -            }
  -        }
  -    } else {
  -        ajp14->endpointCache=NULL;
  +    if( ajp14->endpointCache == NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                      "ajp14.init(): error creating endpoint cache\n");
  +        return JK_ERR;
  +    }
  +    
  +    /* Will grow */
  +    rc=ajp14->endpointCache->init( env, ajp14->endpointCache, -1 );
  +    if( rc!= JK_OK ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                      "ajp14.init(): error creating endpoint cache\n");
  +        return JK_ERR;
       }
   
       if( ajp14->channel == NULL ) {
  
  
  

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