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_endpoint.c jk_handler_discovery.c jk_handler_response.c jk_lb_worker.c jk_map.c jk_msg_buff.c jk_pool.c jk_requtil.c jk_uriMap.c
Date Tue, 04 Dec 2001 23:56:08 GMT
costin      01/12/04 15:56:08

  Modified:    jk/native2/jni jk_jnicb.c
               jk/native2/include jk_pool.h jk_uriMap.h
               jk/native2/common jk_endpoint.c jk_handler_discovery.c
                        jk_handler_response.c jk_lb_worker.c jk_map.c
                        jk_msg_buff.c jk_pool.c jk_requtil.c jk_uriMap.c
  Log:
  One more step.
  
  Use virtual methods for pool. This allows the use of native pools ( == apr_pools ).
  
  The pool alocation is still hardcoded, but that's the only place.
  
  Next step is to hunt mallocs and make sure each object has it's pool.
  
  In the process we should fix jk_uriMap, which seem to have a thread safety problem
  ( it is in uri_map as well ).
  
  Revision  Changes    Path
  1.4       +5 -5      jakarta-tomcat-connectors/jk/native2/jni/jk_jnicb.c
  
  Index: jk_jnicb.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/jni/jk_jnicb.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_jnicb.c	2001/12/04 19:13:04	1.3
  +++ jk_jnicb.c	2001/12/04 23:56:06	1.4
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: JNI callbacks implementation for the JNI in process adapter*
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.3 $                                           *
  + * Version:     $Revision: 1.4 $                                           *
    ***************************************************************************/
   
   #include "jk_jnicb.h"
  @@ -364,10 +364,10 @@
       if(hcnt) {
           ok = JK_FALSE;
   
  -        nhnames = (char **)jk_pool_alloc(ps->pool, hcnt * sizeof(char *));
  -        nhvalues = (char **)jk_pool_alloc(ps->pool, hcnt * sizeof(char *));        
   
  -        shnames = (jstring *)jk_pool_alloc(ps->pool, hcnt * sizeof(jstring));
  -        shvalues = (jstring *)jk_pool_alloc(ps->pool, hcnt * sizeof(jstring));
  +        nhnames = (char **)ps->pool->alloc(ps->pool, hcnt * sizeof(char *));
  +        nhvalues = (char **)ps->pool->alloc(ps->pool, hcnt * sizeof(char *));
           
  +        shnames = (jstring *)ps->pool->alloc(ps->pool, hcnt * sizeof(jstring));
  +        shvalues = (jstring *)ps->pool->alloc(ps->pool, hcnt * sizeof(jstring));
   
           if(nhvalues && nhnames && shnames && shnames) {	    
               for( ; i < hcnt ; i++) {
  
  
  
  1.2       +24 -18    jakarta-tomcat-connectors/jk/native2/include/jk_pool.h
  
  Index: jk_pool.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_pool.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_pool.h	2001/12/01 22:30:20	1.1
  +++ jk_pool.h	2001/12/04 23:56:06	1.2
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: Memory Pool object header file                             *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.1 $                                           *
  + * Version:     $Revision: 1.2 $                                           *
    ***************************************************************************/
   #ifndef _JK_POOL_H
   #define _JK_POOL_H
  @@ -132,10 +132,19 @@
       
       void (*reset)(jk_pool_t *_this);
   
  -    void *(*alloc)(jk_pool_t *_this);
  +    void *(*alloc)(jk_pool_t *_this, size_t size);
   
  -    void *(*strdup)(jk_pool_t *_this, const char *s);
  -        
  +    void *(*realloc)(jk_pool_t *_this, size_t size,
  +                     const void *old, size_t old_sz);
  +
  +    void *(*calloc)(jk_pool_t *_this, size_t size);
  +
  +    void *(*pstrdup)(jk_pool_t *_this, const char *s);
  +
  +    /** Points to the private data. In the case of APR,
  +        it's a apr_pool you can use directly */
  +    void *_private;
  +    
       /* Private data - XXX move to impl */
       unsigned size;      
       unsigned pos;       
  @@ -144,24 +153,21 @@
       unsigned dyn_pos;   
       void     **dynamic;
   };
  -void jk_open_pool(jk_pool_t *p,
  -                  jk_pool_atom_t *buf,
  -                  unsigned size);
  -
  -void jk_close_pool(jk_pool_t *p);
   
  -void jk_reset_pool(jk_pool_t *p);
  +/** Create a pool
  + */
  +int jk_pool_create( jk_pool_t **newPool, jk_pool_t *parent );
   
  -void *jk_pool_alloc(jk_pool_t *p, 
  -                    size_t sz);
  +/** Open a pool using allocated space. The pool can grow by
  +    (m)allocating more storage, but it'll first use buf.
  +    This is used in jk with stack-allocated pools.
  +*/
  +void jk_pool_open(jk_pool_t *p, jk_pool_atom_t *buf, unsigned size);
   
  -void *jk_pool_realloc(jk_pool_t *p, 
  -                      size_t sz,
  -                      const void *old,
  -                      size_t old_sz);
   
  -void *jk_pool_strdup(jk_pool_t *p, 
  -                     const char *s);
  +void jk_open_pool(jk_pool_t *p,
  +                  jk_pool_atom_t *buf,
  +                  unsigned size);
   
   #ifdef __cplusplus
   }
  
  
  
  1.3       +10 -0     jakarta-tomcat-connectors/jk/native2/include/jk_uriMap.h
  
  Index: jk_uriMap.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_uriMap.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_uriMap.h	2001/12/04 18:33:50	1.2
  +++ jk_uriMap.h	2001/12/04 23:56:06	1.3
  @@ -121,6 +121,16 @@
       int (*checkUri)( jk_uriMap_t *_this,
                        char *uri );
   
  +    /** Mapping the uri. To be thread safe, we need to pass a pool.
  +        Or even better, create the jk_service structure already.
  +        mapUri() can set informations on it as well.
  +        
  +        MapUri() method should behave exactly like the native apache2
  +        mapper - we need it since the mapping rules for servlets are
  +        different ( or we don't know yet how to 'tweak' apache config
  +        to do what we need ). Even when we'll know, uriMap will be needed
  +        for other servers. 
  +    */
       struct jk_uriEnv *(*mapUri)(jk_uriMap_t *_this,
                                   const char *vhost,
                                   const char *uri );
  
  
  
  1.2       +3 -4      jakarta-tomcat-connectors/jk/native2/common/jk_endpoint.c
  
  Index: jk_endpoint.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_endpoint.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_endpoint.c	2001/12/04 18:38:05	1.1
  +++ jk_endpoint.c	2001/12/04 23:56:07	1.2
  @@ -59,7 +59,7 @@
    * Description: common stuff for bi-directional protocols ajp13/ajp14.     *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.1 $                                           *
  + * Version:     $Revision: 1.2 $                                           *
    ***************************************************************************/
   
   
  @@ -74,7 +74,7 @@
   void ajp_reset_endpoint(jk_endpoint_t *ae)
   {
       ae->reuse = JK_FALSE;
  -    jk_reset_pool(&(ae->pool));
  +    ae->pool.reset( &ae->pool );
   }
   
   /*
  @@ -87,8 +87,7 @@
       l->jkLog(l, JK_LOG_DEBUG, "In jk_endpoint_t::ajp_close_endpoint\n");
   
       ajp_reset_endpoint(ae);
  -    jk_close_pool(&(ae->pool));
  -
  +    ae->pool.close( &ae->pool );
       {
   	jk_channel_t *channel=ae->worker->channel;
   	int err=channel->close( channel, ae );
  
  
  
  1.4       +10 -10    jakarta-tomcat-connectors/jk/native2/common/jk_handler_discovery.c
  
  Index: jk_handler_discovery.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_handler_discovery.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_handler_discovery.c	2001/12/04 19:06:48	1.3
  +++ jk_handler_discovery.c	2001/12/04 23:56:07	1.4
  @@ -58,7 +58,7 @@
   /**
    * Description: AJP14 Discovery handler
    * Author:      Henri Gomez <hgomez@slib.fr>
  - * Version:     $Revision: 1.3 $                                          
  + * Version:     $Revision: 1.4 $                                          
    */
   
   #include "jk_global.h"
  @@ -169,7 +169,7 @@
           jk_context_item_t **contexts;
           int  capacity = c->capacity + CBASE_INC_SIZE;
           
  -        contexts = (jk_context_item_t **)jk_pool_alloc(&c->p, sizeof(jk_context_item_t
*) * capacity);
  +        contexts = (jk_context_item_t **)c->p.alloc(&c->p, sizeof(jk_context_item_t
*) * capacity);
   
           if (! contexts)
               return JK_FALSE;
  @@ -191,7 +191,7 @@
               char **uris;
               int capacity = ci->capacity + URI_INC_SIZE;
   
  -            uris = (char **)jk_pool_alloc(&c->p, sizeof(char *) * capacity);
  +            uris = (char **)c->p.alloc(&c->p, sizeof(char *) * capacity);
   
           if (! uris)
               return JK_FALSE;
  @@ -218,7 +218,7 @@
           c->contexts = NULL;
   
           if( virtual ) {
  -            c->virtual=jk_pool_strdup(&c->p, virtual);
  +            c->virtual=c->p.pstrdup(&c->p, virtual);
           }
           return JK_TRUE;
       }
  @@ -312,7 +312,7 @@
       }
       
       free(buf);
  -    jk_close_pool(&c->p);
  +    c->p.close(&c->p);
       free(c);
       c = NULL;
   #else 
  @@ -432,7 +432,7 @@
           /* set the virtual name, better to add to a virtual list ? */
   
           if( vname != NULL ) {
  -            c->virtual=  jk_pool_strdup(&c->p, vname);
  +            c->virtual=  c->p.pstrdup(&c->p, vname);
           }
       }
       
  @@ -682,7 +682,7 @@
       if (c) {
   
           if (virtual) {
  -            c->virtual = jk_pool_strdup(&c->p, virtual);
  +            c->virtual = c->p.pstrdup(&c->p, virtual);
   
               if (! c->virtual)
                   return JK_FALSE;
  @@ -776,14 +776,14 @@
       if (context_realloc(c) != JK_TRUE)
           return NULL;
   
  -    ci = (jk_context_item_t *)jk_pool_alloc(&c->p, sizeof(jk_context_item_t));
  +    ci = (jk_context_item_t *)c->p.alloc(&c->p, sizeof(jk_context_item_t));
   
       if (! ci)
           return NULL;
   
       c->contexts[c->size] = ci;
       c->size++;
  -    ci->cbase       = jk_pool_strdup(&c->p, cbase);
  +    ci->cbase       = c->p.pstrdup(&c->p, cbase);
       ci->status      = 0;
       ci->size        = 0;
       ci->capacity    = 0;
  @@ -815,7 +815,7 @@
       if (context_item_realloc(c, ci) == JK_FALSE)
           return JK_FALSE;
   
  -    ci->uris[ci->size] = jk_pool_strdup(&c->p, uri);
  +    ci->uris[ci->size] = c->p.pstrdup(&c->p, uri);
   
       if (ci->uris[ci->size] == NULL)
           return JK_FALSE;
  
  
  
  1.2       +2 -2      jakarta-tomcat-connectors/jk/native2/common/jk_handler_response.c
  
  Index: jk_handler_response.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_handler_response.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_handler_response.c	2001/12/04 18:37:13	1.1
  +++ jk_handler_response.c	2001/12/04 23:56:07	1.2
  @@ -113,8 +113,8 @@
       l->jkLog(l, JK_LOG_DEBUG, "ajp_unmarshal_response: Number of headers is = %d\n",
s->out_headers);
   
       if (s->out_headers) {
  -        s->out_header_names = jk_pool_alloc(p, sizeof(char *) * s->out_headers);
  -        s->out_header_values = jk_pool_alloc(p, sizeof(char *) * s->out_headers);
  +        s->out_header_names = p->alloc(p, sizeof(char *) * s->out_headers);
  +        s->out_header_values = p->alloc(p, sizeof(char *) * s->out_headers);
   
           if (s->out_header_names && s->out_header_values) {
               unsigned i;
  
  
  
  1.4       +8 -8      jakarta-tomcat-connectors/jk/native2/common/jk_lb_worker.c
  
  Index: jk_lb_worker.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_lb_worker.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_lb_worker.c	2001/12/04 19:08:13	1.3
  +++ jk_lb_worker.c	2001/12/04 23:56:07	1.4
  @@ -60,7 +60,7 @@
    *              several workers.                                           *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Based on:                                                               *
  - * Version:     $Revision: 1.3 $                                           *
  + * Version:     $Revision: 1.4 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -257,7 +257,7 @@
               if(rec) {
                   int is_recoverable = JK_FALSE;
                   
  -                s->jvm_route = jk_pool_strdup(s->pool,  rec->name);
  +                s->jvm_route = s->pool->pstrdup(s->pool,  rec->name);
   
                   rc = rec->w->get_endpoint(rec->w, &end, l);
                   if(rc && end) {
  @@ -358,15 +358,15 @@
                                    &num_of_workers) && num_of_workers) {
               unsigned i = 0;
   
  -            p->lb_workers = jk_pool_alloc(&p->p, 
  -                                          num_of_workers * sizeof(worker_record_t));
  +            p->lb_workers = p->p.alloc(&p->p, 
  +                                       num_of_workers * sizeof(worker_record_t));
   
               if(!p->lb_workers) {
                   return JK_FALSE;
               }
   
               for(i = 0 ; i < num_of_workers ; i++) {
  -                p->lb_workers[i].name = jk_pool_strdup(&p->p, worker_names[i]);
  +                p->lb_workers[i].name = p->p.pstrdup(&p->p, worker_names[i]);
                   p->lb_workers[i].lb_factor = jk_get_lb_factor(props, 
                                                                  worker_names[i]);
                   p->lb_workers[i].lb_factor = 1/p->lb_workers[i].lb_factor;
  @@ -461,7 +461,7 @@
                         private_data->num_of_workers,
                         l);
   
  -        jk_close_pool(&private_data->p);
  +        private_data->p.close(&private_data->p);
           free(private_data);
   
           return JK_TRUE;
  @@ -498,10 +498,10 @@
                    private_data->buf, 
                    sizeof(jk_pool_atom_t) * TINY_POOL_SIZE);
   
  -    private_data->name = jk_pool_strdup(&private_data->p, name);          
  +    private_data->name = private_data->p.pstrdup(&private_data->p, name);
         
       if(! private_data->name) {
           l->jkLog(l, JK_LOG_ERROR,"In lb_worker_factory, malloc failed\n");
  -        jk_close_pool(&private_data->p);
  +        private_data->p.close(&private_data->p);
           free(private_data);
           return JK_FALSE;
       }
  
  
  
  1.3       +12 -12    jakarta-tomcat-connectors/jk/native2/common/jk_map.c
  
  Index: jk_map.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_map.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_map.c	2001/12/04 19:09:19	1.2
  +++ jk_map.c	2001/12/04 23:56:07	1.3
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: General purpose map object                                 *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   
   #include "jk_global.h"
  @@ -127,7 +127,7 @@
       int rc = JK_FALSE;
   
       if(m) {
  -        jk_close_pool(&m->p);
  +        m->p.close(&m->p);
           rc = JK_TRUE;
       }
       
  @@ -216,7 +216,7 @@
       if(l) {
           unsigned capacity = 0;
           unsigned idex = 0;    
  -        char *v = jk_pool_strdup(&m->p, l);
  +        char *v = m->p.pstrdup(&m->p, l);
           
           if(!v) {
               return NULL;
  @@ -232,7 +232,7 @@
               l = strtok(NULL, " \t,*")) {
           
               if(idex == capacity) {
  -                ar = jk_pool_realloc(&m->p, 
  +                ar = m->p.realloc(&m->p, 
                                        sizeof(char *) * (capacity + 5),
                                        ar,
                                        sizeof(char *) * capacity);
  @@ -241,7 +241,7 @@
                   }
                   capacity += 5;
               }
  -            ar[idex] = jk_pool_strdup(&m->p, l);
  +            ar[idex] = m->p.pstrdup(&m->p, l);
               idex ++;
           }
           
  @@ -276,7 +276,7 @@
   
               if(m->size < m->capacity) {
                   m->values[m->size] = value;
  -                m->names[m->size] = jk_pool_strdup(&m->p, name);
  +                m->names[m->size] = m->p.pstrdup(&m->p, name);
                   m->size ++;
                   rc = JK_TRUE;
               }
  @@ -331,8 +331,8 @@
                               v = map_replace_properties(v, m);
   
                               if(oldv) {
  -                                char *tmpv = jk_pool_alloc(&m->p, 
  -                                                           strlen(v) + strlen(oldv) + 3);
  +                                char *tmpv = m->p.alloc(&m->p, 
  +                                                        strlen(v) + strlen(oldv) + 3);
                                   if(tmpv) {
                                       char sep = '*';
                                       if(jk_is_some_property(prp, "path")) {
  @@ -346,7 +346,7 @@
                                   }                                
                                   v = tmpv;
                               } else {
  -                                v = jk_pool_strdup(&m->p, v);
  +                                v = m->p.pstrdup(&m->p, v);
                               }
                               if(v) {
                                   void *old = NULL;
  @@ -431,8 +431,8 @@
           void **values;
           int  capacity = m->capacity + CAPACITY_INC_SIZE;
   
  -        names = (char **)jk_pool_alloc(&m->p, sizeof(char *) * capacity);
  -        values = (void **)jk_pool_alloc(&m->p, sizeof(void *) * capacity);
  +        names = (char **)m->p.alloc(&m->p, sizeof(char *) * capacity);
  +        values = (void **)m->p.alloc(&m->p, sizeof(void *) * capacity);
           
           if(values && names) {
               if (m->capacity && m->names) 
  @@ -479,7 +479,7 @@
   	    }
               if(env_value) {
                   int offset=0;
  -                char *new_value = jk_pool_alloc(&m->p, 
  +                char *new_value = m->p.alloc(&m->p, 
                                                   (sizeof(char) * (strlen(rc) + strlen(env_value))));
                   if(!new_value) {
                       break;
  
  
  
  1.4       +3 -3      jakarta-tomcat-connectors/jk/native2/common/jk_msg_buff.c
  
  Index: jk_msg_buff.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_buff.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_msg_buff.c	2001/12/04 19:09:20	1.3
  +++ jk_msg_buff.c	2001/12/04 23:56:07	1.4
  @@ -60,7 +60,7 @@
    * Author:      Costin <costin@costin.dnt.ro>                              *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.3 $                                           *
  + * Version:     $Revision: 1.4 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -197,7 +197,7 @@
   jk_msg_buf_t *jk_b_new(jk_pool_t *p) 
   {
       jk_msg_buf_t *msg = 
  -            (jk_msg_buf_t *)jk_pool_alloc(p, sizeof(jk_msg_buf_t));
  +            (jk_msg_buf_t *)p->alloc(p, sizeof(jk_msg_buf_t));
   
       if(!msg) {
           return NULL;
  @@ -227,7 +227,7 @@
   int jk_b_set_buffer_size(jk_msg_buf_t *msg, 
                            int buffSize) 
   {
  -    unsigned char *data = (unsigned char *)jk_pool_alloc(msg->pool, buffSize);
  +    unsigned char *data = (unsigned char *)msg->pool->alloc(msg->pool, buffSize);
       
       if(!data) {
   	    return -1;
  
  
  
  1.2       +55 -30    jakarta-tomcat-connectors/jk/native2/common/jk_pool.c
  
  Index: jk_pool.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_pool.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_pool.c	2001/12/01 22:38:39	1.1
  +++ jk_pool.c	2001/12/04 23:56:07	1.2
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: Simple memory pool                                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.1 $                                           *
  + * Version:     $Revision: 1.2 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -71,20 +71,7 @@
                                  size_t size);
   
   
  -void jk_open_pool(jk_pool_t *p,
  -                  jk_pool_atom_t *buf,
  -                  unsigned size)
  -{
  -    p->pos  = 0;
  -    p->size = size;
  -    p->buf  = (char *)buf;
  -
  -    p->dyn_pos = 0;
  -    p->dynamic = NULL;
  -    p->dyn_size = 0;
  -}
  -
  -void jk_close_pool(jk_pool_t *p)
  +static void jk_close_pool(jk_pool_t *p)
   {
       if(p) {
           jk_reset_pool(p);
  @@ -94,7 +81,7 @@
       }
   }
   
  -void jk_reset_pool(jk_pool_t *p)
  +static void jk_reset_pool(jk_pool_t *p)
   {
       if(p && p->dyn_pos && p->dynamic) {
           unsigned i;
  @@ -108,9 +95,17 @@
       p->dyn_pos  = 0;
       p->pos      = 0;
   }
  +
  +static void *jk_pool_calloc(jk_pool_t *p, 
  +                           size_t size)
  +{
  +    void *rc=jk_pool_alloc( p, size );
  +    memset( rc, 0, size );
  +    return rc;
  +}
   
  -void *jk_pool_alloc(jk_pool_t *p, 
  -                    size_t size)
  +static void *jk_pool_alloc(jk_pool_t *p, 
  +                           size_t size)
   {
       void *rc = NULL;
   
  @@ -130,10 +125,10 @@
       return rc;
   }
   
  -void *jk_pool_realloc(jk_pool_t *p, 
  -                      size_t sz,
  -                      const void *old,
  -                      size_t old_sz)
  +static void *jk_pool_realloc(jk_pool_t *p, 
  +                             size_t sz,
  +                             const void *old,
  +                             size_t old_sz)
   {
       void *rc;
   
  @@ -149,8 +144,8 @@
       return rc;
   }
   
  -void *jk_pool_strdup(jk_pool_t *p, 
  -                     const char *s)
  +static void *jk_pool_strdup(jk_pool_t *p, 
  +                            const char *s)
   {
       char *rc = NULL;
       if(s && p) {
  @@ -170,7 +165,7 @@
       return rc;
   }
   
  -void jk_dump_pool(jk_pool_t *p, 
  +static void jk_dump_pool(jk_pool_t *p, 
                     FILE *f)
   {
       fprintf(f, "Dumping for pool [%x]\n", p);
  @@ -216,18 +211,48 @@
       return rc;
   }
   
  -int JK_METHOD jk_pool_factory( jk_env_t *env, void **result,
  -                               char *type, char *name)
  -{
  -    jk_pool_t *_this=(jk_pool_t *)calloc( 1, sizeof(jk_pool_t));
  +/* Not implemented yet */
  +int jk_pool_create( jk_pool_t **newPool, jk_pool_t *parent ) {
   
  +    return JK_TRUE;
  +}
  +
  +static void init_methods(jk_pool_t *_this ) {
       _this->open=jk_open_pool;
       _this->close=jk_close_pool;
       _this->reset=jk_reset_pool;
       _this->alloc=jk_pool_alloc;
  -    _this->strdup=jk_pool_strdup;
  +    _this->calloc=jk_pool_calloc;
  +    _this->pstrdup=jk_pool_strdup;
  +    _this->realloc=jk_pool_realloc;
  +}
  +
  +/* Not used yet */
  +int JK_METHOD jk_pool_factory( jk_env_t *env, void **result,
  +                               char *type, char *name)
  +{
  +    jk_pool_t *_this=(jk_pool_t *)calloc( 1, sizeof(jk_pool_t));
  +
  +    init_methods(_this );
   
       *result=_this;
       
       return JK_TRUE;
   }
  +
  +/* that's what jk use to create pools. Deprecated! */
  +void jk_open_pool(jk_pool_t *_this,
  +                  jk_pool_atom_t *buf,
  +                  unsigned size)
  +{
  +    _this->pos  = 0;
  +    _this->size = size;
  +    _this->buf  = (char *)buf;
  +
  +    _this->dyn_pos = 0;
  +    _this->dynamic = NULL;
  +    _this->dyn_size = 0;
  +    init_methods( _this );
  +}
  +
  +
  
  
  
  1.2       +2 -2      jakarta-tomcat-connectors/jk/native2/common/jk_requtil.c
  
  Index: jk_requtil.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_requtil.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_requtil.c	2001/12/04 18:35:04	1.1
  +++ jk_requtil.c	2001/12/04 23:56:07	1.2
  @@ -268,7 +268,7 @@
                       id_start += (1 + strlen(name));
                       if(strlen(id_start)) {
                           char *id_end;
  -                        id_start = jk_pool_strdup(s->pool, id_start);
  +                        id_start = s->pool->pstrdup(s->pool, id_start);
                           if(id_end = strchr(id_start, ';')) {
                               *id_end = '\0';
                           }
  @@ -297,7 +297,7 @@
               id_start += (1 + strlen(name));
               if(strlen(id_start)) {
                   char *id_end;
  -                id_start = jk_pool_strdup(s->pool, id_start);
  +                id_start = s->pool->pstrdup(s->pool, id_start);
                   /* 
                    * The query string is not part of req_uri, however
                    * to be on the safe side lets remove the trailing query 
  
  
  
  1.5       +16 -15    jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c
  
  Index: jk_uriMap.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_uriMap.c	2001/12/04 18:39:45	1.4
  +++ jk_uriMap.c	2001/12/04 23:56:07	1.5
  @@ -67,7 +67,7 @@
    * servlet container.                                                      *
    *                                                                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.4 $                                           *
  + * Version:     $Revision: 1.5 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -136,7 +136,7 @@
           int  capacity = _this->capacity + UW_INC_SIZE;
   
           uwr = (jk_uriEnv_t **)
  -            jk_pool_alloc(&_this->p, sizeof(jk_uriEnv_t *) * capacity);
  +            _this->p.alloc(&_this->p, sizeof(jk_uriEnv_t *) * capacity);
   
           if (! uwr)
               return JK_FALSE;
  @@ -153,7 +153,7 @@
   }
   
   static jk_uriEnv_t *jk_uriMap_createUriEnv(jk_uriMap_t *_this ) {
  -    jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)jk_pool_alloc(&_this->p,
  +    jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)_this->p.alloc(&_this->p,
                                                        sizeof(jk_uriEnv_t));
       memset(uriEnv, 0, sizeof(jk_uriEnv_t));
       
  @@ -183,8 +183,8 @@
   
       uwr = jk_uriMap_createUriEnv(_this);
       
  -    uri = jk_pool_strdup(&_this->p, puri);
  -    worker = jk_pool_strdup(&_this->p, pworker);
  +    uri = _this->p.pstrdup(&_this->p, puri);
  +    worker = _this->p.pstrdup(&_this->p, pworker);
       uwr->workerName = worker;
   
       if (uri==NULL ||
  @@ -227,7 +227,7 @@
           return uwr;
       }
   
  -    uwr->uri = jk_pool_strdup(&_this->p, uri);
  +    uwr->uri = _this->p.pstrdup(&_this->p, uri);
   
       if (!uwr->uri) {
           l->jkLog(l, JK_LOG_ERROR,"Allocation error\n");
  @@ -299,11 +299,6 @@
   
       _this->workerEnv = workerEnv;
                                              
  -    jk_open_pool(&_this->p,_this->buf, 
  -                 sizeof(jk_pool_atom_t) * SMALL_POOL_SIZE);
  -    jk_open_pool(&_this->tp,_this->tbuf,
  -                 sizeof(jk_pool_atom_t) * SMALL_POOL_SIZE);
  -
       sz = map_size(init_data);
   
       for(i = 0; i < sz ; i++) {
  @@ -349,8 +344,8 @@
   
       /* this can't be null ( or a NPE would have been generated */
       
  -    jk_close_pool(&_this->p);
  -    jk_close_pool(&_this->tp);
  +    _this->p.close(&_this->p);
  +    _this->tp.close(&_this->tp);
   }
   
   
  @@ -423,8 +418,9 @@
       url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
           
       if(url_rewrite) {
  -        jk_reset_pool(&_this->tp);
  -        clean_uri = jk_pool_strdup(&_this->tp,uri);
  +        /* XXXXXXXXXX NOT THREAD SAFE ! ???? XXXXXX */
  +        _this->tp.reset(&_this->tp);
  +        clean_uri = _this->tp.pstrdup(&_this->tp,uri);
           url_rewrite = strstr(clean_uri, JK_PATH_SESSION_IDENTIFIER);
           *url_rewrite = '\0';
           if( _this->debug > 0 )
  @@ -520,6 +516,11 @@
       _this = (jk_uriMap_t *)calloc(1,sizeof(jk_uriMap_t));
       _this->size     = 0;
       _this->capacity = 0;
  +
  +    jk_open_pool(&_this->p,_this->buf, 
  +                 sizeof(jk_pool_atom_t) * SMALL_POOL_SIZE);
  +    jk_open_pool(&_this->tp,_this->tbuf,
  +                 sizeof(jk_pool_atom_t) * SMALL_POOL_SIZE);
   
       if(  ! _this) {
           l->jkLog(l, JK_LOG_ERROR, "Allocation error\n");
  
  
  

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