httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental cache_storage.c mod_cache.h mod_mem_cache.c
Date Fri, 24 Aug 2001 17:01:22 GMT
stoddard    01/08/24 10:01:22

  Modified:    modules/experimental cache_storage.c mod_cache.h
                        mod_mem_cache.c
  Log:
  Eliminate a cache_handle leak. cache_handle is now allocated out of the
  request pool.
  
  Revision  Changes    Path
  1.3       +7 -5      httpd-2.0/modules/experimental/cache_storage.c
  
  Index: cache_storage.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_storage.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- cache_storage.c	2001/08/23 19:46:55	1.2
  +++ cache_storage.c	2001/08/24 17:01:21	1.3
  @@ -156,7 +156,6 @@
    */
   int cache_select_url(request_rec *r, const char *types, char *url)
   {
  -    cache_handle *h;
       const char *next = types;
       const char *type;
       apr_status_t rv;
  @@ -164,12 +163,13 @@
                                                                             &cache_module);
   
       /* go through the cache types till we get a match */
  +    cache->handle = apr_palloc(r->pool, sizeof(cache_handle));
  +
       while (next) {
           type = ap_cache_tokstr(r->pool, next, &next);
  -        switch ((rv = cache_run_open_entity(&h, type, url))) {
  +        switch ((rv = cache_run_open_entity(cache->handle, type, url))) {
           case OK: {
               /* cool bananas! */
  -            cache->handle = h;
   /*** loop through returned entities */
   /*** do freshness calculation here */
               cache->fresh = 1;
  @@ -182,10 +182,12 @@
           }
           default: {
               /* oo-er! an error */
  +            cache->handle = NULL;
               return rv;
           }
           }
       }
  +    cache->handle = NULL;
       return DECLINED;
   }
   
  @@ -245,8 +247,8 @@
                                         (cache_handle **hp, const char *type, 
                                         char *url, apr_size_t len),(hp,type,url,len),DECLINED)
   APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(cache, CACHE, int, open_entity,  
  -                                      (cache_handle **hp, const char *type, 
  -                                      char *url),(hp,type,url),DECLINED)
  +                                      (cache_handle *h, const char *type, 
  +                                      char *url),(h,type,url),DECLINED)
   APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(cache, CACHE, int, remove_url, 
                                       (const char *type, char *url),(type,url),OK,DECLINED)
   #if 0
  
  
  
  1.7       +1 -1      httpd-2.0/modules/experimental/mod_cache.h
  
  Index: mod_cache.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mod_cache.h	2001/08/23 19:46:55	1.6
  +++ mod_cache.h	2001/08/24 17:01:21	1.7
  @@ -240,7 +240,7 @@
                             (cache_handle **hp, const char *type,
                              char *url, apr_size_t len))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, open_entity,  
  -                          (cache_handle **hp, const char *type,
  +                          (cache_handle *h, const char *type,
                              char *url))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, remove_url, 
                             (const char *type, char *url))
  
  
  
  1.4       +2 -11     httpd-2.0/modules/experimental/mod_mem_cache.c
  
  Index: mod_mem_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mod_mem_cache.c	2001/08/24 16:46:43	1.3
  +++ mod_mem_cache.c	2001/08/24 17:01:21	1.4
  @@ -263,10 +263,9 @@
       return OK;
   }
   
  -static int open_entity(cache_handle **hp, const char *type, char *key) 
  +static int open_entity(cache_handle *h, const char *type, char *key) 
   {
       cache_object_t *obj;
  -    cache_handle *h;
   
       /* Look up entity keyed to 'url' */
       if (strcasecmp(type, "mem")) {
  @@ -284,13 +283,7 @@
           return DECLINED;
       }
   
  -    /* Allocate the cache_handle and initialize it */
  -    h = malloc(sizeof(cache_handle));
  -    *hp = h;
  -    if (!h) {
  -        /* handle the error */
  -        return DECLINED;
  -    }
  +    /* Initialize the cache_handle */
       h->read_body = &read_body;
       h->read_headers = &read_headers;
       h->write_body = &write_body;
  @@ -319,8 +312,6 @@
       /* Reinit the cache_handle fields? */
       h->cache_obj = NULL;
   
  -    /* The caller should free the cache_handle ? */
  -    free(h);
       return OK;
   }
   
  
  
  

Mime
View raw message