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_workerEnv.c jk_env.c jk_objCache.c jk_worker_lb.c
Date Fri, 31 May 2002 18:09:13 GMT
costin      2002/05/31 11:09:13

  Modified:    jk/native2/common jk_workerEnv.c jk_env.c jk_objCache.c
                        jk_worker_lb.c
  Log:
  Use jk_mutex.
  
  Revision  Changes    Path
  1.50      +24 -14    jakarta-tomcat-connectors/jk/native2/common/jk_workerEnv.c
  
  Index: jk_workerEnv.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_workerEnv.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- jk_workerEnv.c	30 May 2002 18:24:09 -0000	1.49
  +++ jk_workerEnv.c	31 May 2002 18:09:13 -0000	1.50
  @@ -59,7 +59,7 @@
    * Description: Workers controller                                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.49 $                                           *
  + * Version:     $Revision: 1.50 $                                           *
    ***************************************************************************/
   
   #include "jk_env.h"
  @@ -353,6 +353,12 @@
           configFile=wEnv->config->file;
       }
   
  +    jkb=env->createBean2(env, wEnv->mbean->pool,"threadMutex", NULL);
  +    if( jkb != NULL ) {
  +        wEnv->cs=jkb->object;
  +        jkb->init(env, jkb );
  +    }
  +
       if( wEnv->logger_name!=NULL){
           jkb=env->getBean(env,wEnv->logger_name);
           if (jkb == NULL){
  @@ -550,8 +556,8 @@
       jk_bean_t *jkb;
       int csOk;
       
  -    JK_ENTER_CS(&wEnv->cs, csOk);
  -    if( !csOk ) return JK_ERR;
  +    if( wEnv->cs != NULL ) 
  +        wEnv->cs->lock( env, wEnv->cs );
   
       ch->mbean->id=wEnv->channel_map->size( env, wEnv->channel_map );
       wEnv->channel_map->add(env, wEnv->channel_map, ch->mbean->name, ch);
  @@ -562,7 +568,8 @@
       if( jkb == NULL ) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
                         "workerEnv.addChannel(): Can't find ajp13 worker\n" );
  -        JK_LEAVE_CS( &wEnv->cs, csOk );
  +        if( wEnv->cs != NULL ) 
  +            wEnv->cs->unLock( env, wEnv->cs );
           return JK_ERR;
       }
       ch->worker=jkb->object;
  @@ -570,7 +577,8 @@
       ch->worker->channel=ch;
               
       /* XXX Set additional parameters - use defaults otherwise */
  -    JK_LEAVE_CS( &wEnv->cs, csOk );
  +    if( wEnv->cs != NULL ) 
  +        wEnv->cs->unLock( env, wEnv->cs );
   
       return JK_OK;
   }
  @@ -579,9 +587,8 @@
   {
       int csOk;
       
  -    JK_ENTER_CS(&wEnv->cs, csOk);
  -    if( !csOk ) return JK_ERR;
  -
  +    if( wEnv->cs != NULL ) 
  +        wEnv->cs->lock( env, wEnv->cs );
       {
           int pos=wEnv->endpointMap->size( env, wEnv->endpointMap );
           
  @@ -590,7 +597,8 @@
   
           ep->mbean->init( env, ep->mbean );
       }
  -    JK_LEAVE_CS( &wEnv->cs, csOk );
  +    if( wEnv->cs != NULL ) 
  +        wEnv->cs->unLock( env, wEnv->cs );
       return JK_OK;
   }
   
  @@ -602,8 +610,8 @@
       jk_worker_t *oldW = NULL;
       int csOk;
       
  -    JK_ENTER_CS(&wEnv->cs, csOk);
  -    if( !csOk ) return JK_ERR;
  +    if( wEnv->cs != NULL ) 
  +        wEnv->cs->lock( env, wEnv->cs ); 
   
       w->workerEnv=wEnv;
   
  @@ -614,6 +622,8 @@
       err=w->rPoolCache->init( env, w->rPoolCache,
                                1024 ); /* XXX make it unbound */
   
  +    fprintf( stderr, "XXXWE.addWorker 2 %p %p\n", w, w->rPoolCache );
  +
       wEnv->worker_map->put(env, wEnv->worker_map, w->mbean->name, w, (void
*)&oldW);
               
       if(oldW!=NULL) {
  @@ -624,7 +634,8 @@
               oldW->mbean->destroy(env, oldW->mbean);
       }
       
  -    JK_LEAVE_CS( &wEnv->cs, csOk );
  +    if( wEnv->cs != NULL ) 
  +        wEnv->cs->unLock( env, wEnv->cs );
       return JK_OK;
   }
   
  @@ -787,7 +798,6 @@
           env->alias(env, "shm:", "shm");
           wEnv->shm=(jk_shm_t *)jkb->object;
       }
  -    JK_INIT_CS(&(wEnv->cs), csOk);
  -    
  +
       return JK_OK;
   }
  
  
  
  1.33      +4 -3      jakarta-tomcat-connectors/jk/native2/common/jk_env.c
  
  Index: jk_env.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_env.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- jk_env.c	29 May 2002 17:51:23 -0000	1.32
  +++ jk_env.c	31 May 2002 18:09:13 -0000	1.33
  @@ -507,13 +507,14 @@
       
       jk2_map_default_create( env, & env->_registry, env->globalPool );
       jk2_map_default_create( env, & env->_objects, env->globalPool );
  +
  +    env->tmpPool=env->globalPool->create(env, env->globalPool, HUGE_POOL_SIZE);;
  +
  +    jk2_registry_init(env);
       
       env->envCache= jk2_objCache_create( env, env->globalPool  );
       env->envCache->init( env, env->envCache, 64 );
       env->envCache->maxSize=-1;
  -    env->tmpPool=env->globalPool->create(env, env->globalPool, HUGE_POOL_SIZE);;
  -
  -    jk2_registry_init(env);
   }
   
   
  
  
  
  1.7       +41 -46    jakarta-tomcat-connectors/jk/native2/common/jk_objCache.c
  
  Index: jk_objCache.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_objCache.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_objCache.c	25 Apr 2002 18:51:15 -0000	1.6
  +++ jk_objCache.c	31 May 2002 18:09:13 -0000	1.7
  @@ -72,44 +72,39 @@
       if(_this->size <= 0 )
           return JK_ERR;
   
  -    
  -    JK_ENTER_CS(&_this->cs, rc);
  -    if(rc==JK_TRUE) {
  -
  -        rc=JK_FALSE;
  +    if( _this->cs != NULL )
  +        _this->cs->lock(env, _this->cs );
   
  -        if( _this->count >= _this->size && _this->maxSize== -1 ) {
  -            /* Realloc */
  -            void **oldData=_this->data;
  -            _this->data =
  -                (void **)_this->pool->calloc(env, _this->pool,
  -                                             2 * sizeof(void *) * _this->size);
  -            memcpy( _this->data, oldData, _this->size );
  -            _this->size *= 2;
  -            /* XXX Can we destroy the old data ? Probably not.
  -               It may be better to have a list - but it's unlikely
  -               we'll have too many reallocations */
  -        }
  -
  -        if( _this->count < _this->size ) {
  -            _this->data[_this->count++]=obj;
  -        }
  -
  -        JK_LEAVE_CS(&_this->cs, rc);
  -        if(rc==JK_TRUE) {
  -            /*   l->jkLog(l, JK_LOG_DEBUG, "Return endpoint to pool\n"); */
  -            return JK_OK;
  -        }
  +    rc=JK_FALSE;
  +    
  +    if( _this->count >= _this->size && _this->maxSize== -1 ) {
  +        /* Realloc */
  +        void **oldData=_this->data;
  +        _this->data =
  +            (void **)_this->pool->calloc(env, _this->pool,
  +                                         2 * sizeof(void *) * _this->size);
  +        memcpy( _this->data, oldData, _this->size );
  +        _this->size *= 2;
  +        /* XXX Can we destroy the old data ? Probably not.
  +           It may be better to have a list - but it's unlikely
  +           we'll have too many reallocations */
       }
  +    
  +    if( _this->count < _this->size ) {
  +        _this->data[_this->count++]=obj;
  +    }
  +    
  +    if( _this->cs != NULL )
  +        _this->cs->unLock(env, _this->cs );
   
  -    /* Can't enter CS */ 
  -    return JK_ERR; 
  +    return JK_OK;
   }
   
   static int
   jk2_objCache_init(jk_env_t *env, jk_objCache_t *_this, int cacheSize ) {
       int i;
  -
  +    jk_bean_t *jkb;
  +    
       if( cacheSize <= 0 ) {
           _this->size= 64;
       } else {
  @@ -125,11 +120,10 @@
       if( _this->data==NULL )
           return JK_ERR;
       
  -    JK_INIT_CS(&(_this->cs), i);
  -    if (!i) {
  -        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                      "objCache.create(): Can't init CS\n");
  -        return JK_ERR;
  +    jkb=env->createBean2(env, _this->pool,"threadMutex", NULL);
  +    if( jkb != NULL ) {
  +        _this->cs=jkb->object;
  +        jkb->init(env, jkb );
       }
   
       return JK_OK;
  @@ -139,7 +133,8 @@
   jk2_objCache_destroy(jk_env_t *env, jk_objCache_t *_this ) {
       int i;
   
  -    JK_DELETE_CS(&(_this->cs), i);
  +    if( _this->cs != NULL ) 
  +        _this->cs->mbean->destroy( env, _this->cs->mbean );
   
       _this->count=0;
       /* Nothing to free, we use pools */
  @@ -154,18 +149,18 @@
       int rc;
       void *ae=NULL;
   
  -    JK_ENTER_CS(&_this->cs, rc);
  -    if (rc==JK_TRUE) {
  -        if( _this->count > 0 ) {
  -            _this->count--;
  -            ae=_this->data[ _this->count ];
  -        }
  +    if( _this->cs != NULL )
  +        _this->cs->lock(env, _this->cs );
   
  -        JK_LEAVE_CS(&_this->cs, rc);
  -
  -        return ae;
  +    if( _this->count > 0 ) {
  +        _this->count--;
  +        ae=_this->data[ _this->count ];
       }
  -    return NULL;
  +
  +    if( _this->cs != NULL )
  +        _this->cs->unLock(env, _this->cs );
  +
  +    return ae;
   }
   
   jk_objCache_t *jk2_objCache_create(jk_env_t *env, jk_pool_t *pool ) {
  
  
  
  1.18      +0 -1      jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c
  
  Index: jk_worker_lb.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_lb.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jk_worker_lb.c	16 May 2002 21:03:45 -0000	1.17
  +++ jk_worker_lb.c	31 May 2002 18:09:13 -0000	1.18
  @@ -69,7 +69,6 @@
   #include "jk_config.h"
   #include "jk_env.h"
   #include "jk_requtil.h"
  -#include "jk_mt.h"
   
   #define DEFAULT_LB_FACTOR           (1.0)
   
  
  
  

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