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 cache_util.c mod_cache.h mod_disk_cache.c mod_disk_cache.dsp mod_mem_cache.c
Date Sun, 03 Feb 2002 19:04:16 GMT
stoddard    02/02/03 11:04:16

  Modified:    modules/experimental cache_storage.c cache_util.c
                        mod_cache.h mod_disk_cache.c mod_disk_cache.dsp
                        mod_mem_cache.c
  Log:
  mod_disk_cache cleanup.  Pass request_rec on the open_entity call.
  
  Revision  Changes    Path
  1.13      +3 -3      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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- cache_storage.c	3 Feb 2002 06:24:55 -0000	1.12
  +++ cache_storage.c	3 Feb 2002 19:04:15 -0000	1.13
  @@ -171,7 +171,7 @@
   
       while (next) {
           type = ap_cache_tokstr(r->pool, next, &next);
  -        switch ((rv = cache_run_open_entity(cache->handle, r->pool, type, key)))
{
  +        switch ((rv = cache_run_open_entity(cache->handle, r, type, key))) {
           case OK: {
               info = &(cache->handle->cache_obj->info);
               /* XXX:
  @@ -244,8 +244,8 @@
                                         const char *urlkey, apr_size_t len),
                                         (h, r, type,urlkey,len),DECLINED)
   APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(cache, CACHE, int, open_entity,  
  -                                      (cache_handle_t *h, apr_pool_t *p, const char *type,

  -                                      const char *urlkey),(h,p,type,urlkey),
  +                                      (cache_handle_t *h, request_rec *r, const char *type,

  +                                      const char *urlkey),(h,r,type,urlkey),
                                         DECLINED)
   APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(cache, CACHE, int, remove_url, 
                                       (const char *type, const char *urlkey),
  
  
  
  1.8       +6 -89     httpd-2.0/modules/experimental/cache_util.c
  
  Index: cache_util.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_util.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- cache_util.c	3 Feb 2002 06:28:52 -0000	1.7
  +++ cache_util.c	3 Feb 2002 19:04:15 -0000	1.8
  @@ -218,7 +218,7 @@
   /*
    * Converts apr_time_t hex digits to a time integer
    */
  -static apr_time_t ap_cache_hex2msec(const char *x)
  +apr_time_t ap_cache_hex2msec(const char *x)
   {
       int i, ch;
       apr_time_t j;
  @@ -238,7 +238,7 @@
   /*
    * Converts a time integer to apr_time_t hex digits
    */
  -static void ap_cache_msec2hex(apr_time_t j, char *y)
  +void ap_cache_msec2hex(apr_time_t j, char *y)
   {
       int i, ch;
   
  @@ -253,80 +253,6 @@
       y[sizeof(j) * 2] = '\0';
   }
   
  -int mkdir_structure(char *file, const char *root)
  -{
  -    
  -    /* XXX TODO: Use APR to make a root directory. Do some sanity checking... */
  -    return 0;
  -}
  -
  -cache_info * create_cache_el(apr_pool_t *p, cache_handle_t *h, const char *name)
  -{
  -    cache_info *info = apr_pcalloc(p, sizeof(cache_info));
  -    memset(info, '\0', sizeof(cache_info));
  -    info->name = (char *)name;
  -    return info;
  -}
  -
  -/* These two functions get and put state information into the data 
  - * file for an ap_cache_el, this state information will be read 
  - * and written transparent to clients of this module 
  - */
  -int file_cache_read_mydata(apr_file_t *fd, cache_info *info, request_rec *r)
  -{
  -    apr_status_t rv;
  -    char urlbuff[1034];
  -    int urllen = sizeof(urlbuff);
  -    int offset=0;
  -    char * temp;
  -
  -    if(!info->hdrsfile) {
  -        return APR_NOTFOUND;
  -    }
  -
  -    /* read the data from the cache file */
  -    /* format
  -     * date SP expire SP count CRLF
  -     * dates are stored as hex seconds since 1970
  -     */
  -    rv = apr_file_gets(&urlbuff[0], urllen, fd);
  -    if (rv != APR_SUCCESS) {
  -        return rv;
  -    }
  -
  -    if ((temp = strchr(&urlbuff[0], '\n')) != NULL) /* trim off new line character
*/
  -        *temp = '\0';      /* overlay it with the null terminator */
  -
  -    if (!apr_date_checkmask(urlbuff, "&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&"))
{
  -        return APR_EGENERAL;
  -    }
  -
  -    info->date = ap_cache_hex2msec(urlbuff + offset);
  -    offset += (sizeof(info->date)*2) + 1;
  -    info->expire = ap_cache_hex2msec(urlbuff + offset);
  -    offset += (sizeof(info->expire)*2) + 1;
  -    info->version = ap_cache_hex2msec(urlbuff + offset);
  -    
  -    /* check that we have the same URL */
  -    rv = apr_file_gets(&urlbuff[0], urllen, fd);
  -    if (rv != APR_SUCCESS) {
  -        return rv;
  -    }
  -
  -    if ((temp = strchr(&urlbuff[0], '\n')) != NULL) { /* trim off new line character
*/
  -        *temp = '\0';      /* overlay it with the null terminator */
  -    }
  -
  -    if (strncmp(urlbuff, "X-NAME: ", 7) != 0) {
  -        return APR_EGENERAL;
  -    }
  -    if (strcmp(urlbuff + 8, info->name) != 0) {
  -        return APR_EGENERAL;
  -    }
  -    
  -    return APR_SUCCESS;
  -}
  -
   static void cache_hash(const char *it, char *val, int ndepth, int nlength)
   {
       apr_md5_ctx_t context;
  @@ -369,18 +295,9 @@
       val[i + 22 - k] = '\0';
   }
   
  -static char *generate_name(apr_pool_t *p, cache_handle_t *h, const char *name)
  -{
  -    char hashfile[66], *filebase;
  -    cache_hash(name, hashfile, h->dirlevels, h->dirlength);
  -    filebase = apr_pstrcat(p, h->root, "/", hashfile, "%s", NULL);
  -    return filebase;
  -}
  -char *header_file(cache_handle_t *h, apr_pool_t *p, const char *name)
  -{
  -    return apr_psprintf(p, generate_name(p, h, name), CACHE_HEADER_SUFFIX);
  -}
  -char *data_file(cache_handle_t *h, apr_pool_t *p, const char *name)
  +char *generate_name(apr_pool_t *p, int dirlevels, int dirlength, const char *name)
   {
  -    return apr_psprintf(p, generate_name(p, h, name), CACHE_DATA_SUFFIX);
  +    char hashfile[66];
  +    cache_hash(name, hashfile, dirlevels, dirlength);
  +    return apr_pstrdup(p, hashfile);
   }
  
  
  
  1.16      +6 -24     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- mod_cache.h	3 Feb 2002 06:24:55 -0000	1.15
  +++ mod_cache.h	3 Feb 2002 19:04:15 -0000	1.16
  @@ -114,13 +114,6 @@
   #define MIN(a,b)                ((a) < (b) ? (a) : (b))
   #endif
   
  -/* Used by mod_disk_cache 
  - * XXX: Perhaps these should be moved to a mod_disk_cache header
  - * file? 
  - */
  -#define CACHE_HEADER_SUFFIX ".header"
  -#define CACHE_DATA_SUFFIX   ".data"
  -
   /* default completion is 60% */
   #define DEFAULT_CACHE_COMPLETION (60)
   #define MAX_URL_LENGTH 1024
  @@ -192,10 +185,6 @@
       void *vobj;         /* Opaque portion (specific to the cache implementation) of the
cache object */
       apr_size_t count;   /* Number of body bytes written to the cache so far */
       int complete;
  -    /* Used by mod_disk_cache: name of the temporary file, 
  -     * used for cache element creation 
  -     */
  -    char *tempfile;
   };
   
   typedef struct cache_handle cache_handle_t;
  @@ -206,13 +195,6 @@
       int (*write_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *b);
       int (*read_headers) (cache_handle_t *h, request_rec *r);
       int (*read_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); 
  -
  -    /* These fields were added for mod_disk_cache but just
  -     * use unnecessary storage in mod_mem_cache.
  -     */
  -    const char *root;           /* the location of the cache directory */
  -    int dirlevels;              /* Number of levels of subdirectories */
  -    int dirlength;              /* Length of subdirectory names */   
   };
   
   /* per request cache information */
  @@ -226,13 +208,13 @@
   
   
   /* cache_util.c */
  -cache_info *create_cache_el(apr_pool_t *p, cache_handle_t *h, const char *name); 
  -char *data_file(cache_handle_t *h, apr_pool_t *p, const char *name);
  -char *header_file(cache_handle_t *h, apr_pool_t *p, const char *name);
  -int file_cache_read_mydata(apr_file_t *fd, cache_info *info, request_rec *r);
  +/**
  + *
  + */
   apr_time_t ap_cache_hex2msec(const char *x);
   void ap_cache_msec2hex(apr_time_t j, char *y);
  -
  +char *generate_name(apr_pool_t *p, int dirlevels, int dirlength, 
  +                    const char *name);
   int ap_cache_request_is_conditional(request_rec *r);
   void ap_cache_reset_output_filters(request_rec *r);
   const char *ap_cache_get_cachetype(request_rec *r, cache_server_conf *conf, const char
*url);
  @@ -286,7 +268,7 @@
                             (cache_handle_t *h, request_rec *r, const char *type,
                              const char *urlkey, apr_size_t len))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, open_entity,  
  -                          (cache_handle_t *h, apr_pool_t *p, const char *type,
  +                          (cache_handle_t *h, request_rec *r, const char *type,
                              const char *urlkey))
   APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, remove_url, 
                             (const char *type, const char *urlkey))
  
  
  
  1.14      +215 -115  httpd-2.0/modules/experimental/mod_disk_cache.c
  
  Index: mod_disk_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_disk_cache.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- mod_disk_cache.c	3 Feb 2002 06:14:10 -0000	1.13
  +++ mod_disk_cache.c	3 Feb 2002 19:04:15 -0000	1.14
  @@ -65,6 +65,17 @@
   #include "util_script.h"
   
   /*
  + * disk_cache_object_t
  + * Pointed to by cache_object_t::vobj
  + */
  +typedef struct disk_cache_object {
  +    const char *root;           /* the location of the cache directory */
  +    char *tempfile;
  +    int dirlevels;              /* Number of levels of subdirectories */
  +    int dirlength;              /* Length of subdirectory names */   
  +} disk_cache_object_t;
  +
  +/*
    * mod_disk_cache configuration
    */
   typedef struct {
  @@ -86,12 +97,6 @@
       int maxgcmem;                /* maximum memory used by garbage collection */
   } disk_cache_conf;
   
  -apr_status_t file_cache_el_final(cache_info *info, cache_handle_t *h, request_rec *r);
  -static int file_cache_write_mydata(apr_file_t *fd , cache_info *info, request_rec *r);
  -
  -/* XXX: This is defined in cache_util... Needs implementing */
  -extern int mkdir_structure(char *file, const char *root);
  -
   module AP_MODULE_DECLARE_DATA disk_cache_module;
   
   /* Forward declarations */
  @@ -101,12 +106,180 @@
   static int read_headers(cache_handle_t *h, request_rec *r);
   static int read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb);
   
  +/*
  + * Local static functions
  + */
  +#define CACHE_HEADER_SUFFIX ".header"
  +#define CACHE_DATA_SUFFIX   ".data"
  +static char *header_file(apr_pool_t *p, int dirlevels, int dirlength, 
  +                         const char *root, const char *name)
  +{
  +    char *hashfile;
  +    hashfile = generate_name(p, dirlevels, dirlength, name);
  +    return apr_pstrcat(p, root, "/", hashfile, CACHE_HEADER_SUFFIX);
  +}
  +
  +static char *data_file(apr_pool_t *p, int dirlevels, int dirlength, 
  +                       const char *root, const char *name)
  +{
  +    char *hashfile;
  +    hashfile = generate_name(p, dirlevels, dirlength, name);
  +    return apr_pstrcat(p, root, "/", hashfile, CACHE_DATA_SUFFIX);
  +}
  +
  +static int mkdir_structure(char *file, const char *root)
  +{
  +    
  +    /* XXX TODO: Use APR to make a root directory. Do some sanity checking... */
  +    return 0;
  +}
  +
  +static apr_status_t file_cache_el_final(cache_info *info, cache_handle_t *h, request_rec
*r)
  +{
  +    disk_cache_conf *conf = ap_get_module_config(r->server->module_config,
  +                                                 &disk_cache_module);
  +    disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
  +
  +    /* move the data over */
  +    if (info->fd) {
  +        apr_file_flush(info->fd);
  +        if (!info->datafile) info->datafile = data_file(r->pool, conf->dirlevels,
conf->dirlength,
  +                                                        conf->cache_root, h->cache_obj->key);
  +        if (unlink(info->datafile)) {
  +            mkdir_structure(info->datafile, conf->cache_root);
  +        }
  +        else {
  +            /* XXX log */
  +        }
  +        if (link(dobj->tempfile, info->datafile) == -1) {
  +            /* XXX log */
  +        }
  +        else {
  +            /* XXX log message */
  +        }
  +       if (unlink(dobj->tempfile) == -1) {
  +           /* XXX log message */
  +       }
  +       else {
  +           /* XXX log message */
  +       }
  +   }
  +   if (info->fd) {
  +       apr_file_close(info->fd);     /* if you finalize, you are done writing, so close
it */
  +       info->fd = 0;
  +       /* XXX log */
  +   }
  +
  +   return APR_SUCCESS;
  +}
  +
  +
  +/* These two functions get and put state information into the data 
  + * file for an ap_cache_el, this state information will be read 
  + * and written transparent to clients of this module 
  + */
  +static int file_cache_read_mydata(apr_file_t *fd, cache_info *info, request_rec *r)
  +{
  +    apr_status_t rv;
  +    char urlbuff[1034];
  +    int urllen = sizeof(urlbuff);
  +    int offset=0;
  +    char * temp;
  +
  +    if(!info->hdrsfile) {
  +        return APR_NOTFOUND;
  +    }
  +
  +    /* read the data from the cache file */
  +    /* format
  +     * date SP expire SP count CRLF
  +     * dates are stored as hex seconds since 1970
  +     */
  +    rv = apr_file_gets(&urlbuff[0], urllen, fd);
  +    if (rv != APR_SUCCESS) {
  +        return rv;
  +    }
  +
  +    if ((temp = strchr(&urlbuff[0], '\n')) != NULL) /* trim off new line character
*/
  +        *temp = '\0';      /* overlay it with the null terminator */
  +
  +    if (!apr_date_checkmask(urlbuff, "&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&"))
{
  +        return APR_EGENERAL;
  +    }
  +
  +    info->date = ap_cache_hex2msec(urlbuff + offset);
  +    offset += (sizeof(info->date)*2) + 1;
  +    info->expire = ap_cache_hex2msec(urlbuff + offset);
  +    offset += (sizeof(info->expire)*2) + 1;
  +    info->version = ap_cache_hex2msec(urlbuff + offset);
  +    
  +    /* check that we have the same URL */
  +    rv = apr_file_gets(&urlbuff[0], urllen, fd);
  +    if (rv != APR_SUCCESS) {
  +        return rv;
  +    }
  +
  +    if ((temp = strchr(&urlbuff[0], '\n')) != NULL) { /* trim off new line character
*/
  +        *temp = '\0';      /* overlay it with the null terminator */
  +    }
  +
  +    if (strncmp(urlbuff, "X-NAME: ", 7) != 0) {
  +        return APR_EGENERAL;
  +    }
  +    if (strcmp(urlbuff + 8, info->name) != 0) {
  +        return APR_EGENERAL;
  +    }
  +    
  +    return APR_SUCCESS;
  +}
  +
  +static int file_cache_write_mydata(apr_file_t *fd , cache_info *info, request_rec *r)
  +{
  +    apr_status_t rc;
  +    char *buf;
  +    apr_size_t amt;
  +
  +    char	dateHexS[sizeof(apr_time_t) * 2 + 1];
  +    char	expireHexS[sizeof(apr_time_t) * 2 + 1];
  +    char	verHexS[sizeof(apr_time_t) * 2 + 1];
  +    
  +    if (!r->headers_out) {
  +        /* XXX log message */
  +        return 0;
  +    }
  +
  +    ap_cache_msec2hex(info->date, dateHexS);
  +    ap_cache_msec2hex(info->expire, expireHexS);
  +    ap_cache_msec2hex(info->version++, verHexS);
  +    buf = apr_pstrcat(r->pool, dateHexS, " ", expireHexS, " ", verHexS, "\n", NULL);
  +    amt = strlen(buf);
  +    rc = apr_file_write(fd, buf, &amt);
  +    if (rc != APR_SUCCESS) {
  +        /* XXX log message */
  +        return 0;
  +    }
  +
  +    buf = apr_pstrcat(r->pool, "X-NAME: ", info->name, "\n", NULL);
  +    amt = strlen(buf);
  +    rc = apr_file_write(fd, buf, &amt);
  +    if (rc != APR_SUCCESS) {
  +        /* XXX log message */
  +        return 0;
  +    }
  +    return 1;
  +}
  +
  +/*
  + * Hook and mod_cache callback functions
  + */
   static int create_entity(cache_handle_t *h, request_rec *r,
                            const char *type, 
                            const char *key, 
                            apr_size_t len)
   { 
       cache_object_t *obj;
  +    disk_cache_object_t *dobj;
  +
       cache_info *info;
   #ifdef AS400
       char tempfile[L_tmpnam];	/* L_tmpnam defined in stdio.h */
  @@ -116,23 +289,17 @@
   	return DECLINED;
       }
   
  -    /* Allocate and initialize cache_object_t */
  -    obj = apr_pcalloc(r->pool, sizeof(cache_object_t));
  -
  -    if (!obj) {
  -	return DECLINED;
  -    }
  +    /* Allocate and initialize cache_object_t and disk_cache_object_t */
  +    obj = apr_pcalloc(r->pool, sizeof(*obj));
  +    obj->vobj = dobj = apr_pcalloc(r->pool, sizeof(*dobj));
   
       obj->key = apr_pcalloc(r->pool, (strlen(key) + 1));
  -    if (!obj->key) {
  -	return DECLINED;
  -    }
  -
       strncpy(obj->key, key, strlen(key) + 1);
       obj->info.len = len;
       obj->complete = 0;   /* Cache object is not complete */
   
  -    info = create_cache_el(r->pool, h, key);
  +    info = apr_pcalloc(r->pool, sizeof(cache_info));
  +    info->name = key;
       obj->info = *(info);
   
   #ifdef AS400
  @@ -175,11 +342,14 @@
       return OK;
   }
   
  -static int open_entity(cache_handle_t *h, apr_pool_t *p, const char *type, const char *key)
  +static int open_entity(cache_handle_t *h, request_rec *r, const char *type, const char
*key)
   {
  +    disk_cache_conf *conf = ap_get_module_config(r->server->module_config, 
  +                                                 &disk_cache_module);
       apr_status_t ret = DECLINED;
       apr_status_t rc;
  -    char *data = data_file(h, p, key);
  +    char *data = data_file(r->pool, conf->dirlevels, conf->dirlength, 
  +                           conf->cache_root, key);
       apr_file_t *fd;
       apr_finfo_t finfo;
       cache_object_t *obj;
  @@ -190,16 +360,18 @@
   	return DECLINED;
       }
   
  -    obj = apr_pcalloc(p, sizeof(cache_object_t));
  +    obj = apr_pcalloc(r->pool, sizeof(cache_object_t));
       obj->key = key;
   
  -    if((rc = apr_file_open(&fd, data, APR_WRITE | APR_READ | APR_BINARY, 0, p)) ==
APR_SUCCESS)  /*  Open the file  */
  -    {
  -	info = create_cache_el(p, h, key);
  +    rc = apr_file_open(&fd, data, APR_WRITE | APR_READ | APR_BINARY, 0, r->pool);
  +    if (rc == APR_SUCCESS) {
  +        info = apr_pcalloc(r->pool, sizeof(cache_info));
  +        info->name = key;
           /* XXX log message */
   	info->fd = fd;
   	info->datafile = data;
  -	info->hdrsfile = header_file(h, p, key);
  +	info->hdrsfile = header_file(r->pool, conf->dirlevels, conf->dirlength, 
  +                                     conf->cache_root, key);
   	rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, fd);
   	if (rc == APR_SUCCESS)
   	    info->file_size = finfo.size;
  @@ -234,7 +406,6 @@
   
       /* Null out the cache object pointer so next time we start from scratch  */
       h->cache_obj = NULL;
  -
       return OK;
   }
   
  @@ -282,8 +453,7 @@
       }
   
       /* XXX log */
  -    if(rv = file_cache_read_mydata(fd, info, r) != APR_SUCCESS)
  -    {
  +    if(rv = file_cache_read_mydata(fd, info, r) != APR_SUCCESS) {
           /* XXX log message */
           apr_file_close(fd);
           return rv;
  @@ -294,12 +464,11 @@
        */
       ap_scan_script_header_err(r, fd, NULL);
    
  -    apr_table_setn(r->headers_out, "Content-Type", ap_make_content_type(r,
  -        r->content_type));                           /* Set content type   */
  +    apr_table_setn(r->headers_out, "Content-Type", 
  +                   ap_make_content_type(r, r->content_type));
   
       rv = apr_file_gets(&urlbuff[0], urllen, fd);           /* Read status  */
  -    if (rv != APR_SUCCESS)
  -    {
  +    if (rv != APR_SUCCESS) {
           /* XXX log message */
   	return rv;
       }
  @@ -307,8 +476,7 @@
       r->status = atoi(urlbuff);                           /* Save status line into request
rec  */
   
       rv = apr_file_gets(&urlbuff[0], urllen, fd);               /* Read status line
*/
  -    if (rv != APR_SUCCESS)
  -    {
  +    if (rv != APR_SUCCESS) {
           /* XXX log message */
   	return rv;
       }
  @@ -318,9 +486,7 @@
   
       r->status_line = apr_pstrdup(r->pool, urlbuff);            /* Save status line
into request rec  */
   
  -
       apr_file_close(fd);
  -
       return APR_SUCCESS;
   }
   
  @@ -349,7 +515,11 @@
       apr_size_t amt;
       
       if (!info->fd)  {
  -        if(!info->hdrsfile) info->hdrsfile = header_file(h, r->pool, h->cache_obj->key);
  +        if(!info->hdrsfile) info->hdrsfile = header_file(r->pool, 
  +                                                         conf->dirlevels, 
  +                                                         conf->dirlength, 
  +                                                         conf->cache_root,
  +                                                         h->cache_obj->key);
           if(unlink(info->hdrsfile)) /* if we can remove it, we clearly don't have to
build the dirs */
               mkdir_structure(info->hdrsfile, conf->cache_root);
           else {
  @@ -397,12 +567,14 @@
   {
       apr_bucket *e;
       apr_status_t rv;
  +    disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
       cache_info *info = &(h->cache_obj->info);
  - 
  -    if(!info->fd) {
  -        if ((rv = apr_file_open(&info->fd, h->cache_obj->tempfile, 
  -                                APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED,
  -                                APR_UREAD | APR_UWRITE, r->pool)) != APR_SUCCESS) {
  +
  +    if (!info->fd) {
  +        rv = apr_file_open(&info->fd, dobj->tempfile, 
  +                           APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED,
  +                           APR_UREAD | APR_UWRITE, r->pool);
  +        if (rv != APR_SUCCESS) {
               return DECLINED;
           }
       }
  @@ -418,79 +590,6 @@
       return OK;	
   }
   
  -static int file_cache_write_mydata(apr_file_t *fd , cache_info *info, request_rec *r)
  -{
  -    apr_status_t rc;
  -    char *buf;
  -    apr_size_t amt;
  -
  -    char	dateHexS[sizeof(apr_time_t) * 2 + 1];
  -    char	expireHexS[sizeof(apr_time_t) * 2 + 1];
  -    char	verHexS[sizeof(apr_time_t) * 2 + 1];
  -    
  -    if(!r->headers_out)
  -    {
  -        /* XXX log message */
  -        return 0;
  -    }
  -
  -    ap_cache_msec2hex(info->date, dateHexS);
  -    ap_cache_msec2hex(info->expire, expireHexS);
  -    ap_cache_msec2hex(info->version++, verHexS);
  -    buf = apr_pstrcat(r->pool, dateHexS, " ", expireHexS, " ", verHexS, "\n", NULL);
  -    amt = strlen(buf);
  -    rc = apr_file_write(fd, buf, &amt);
  -    if(rc != APR_SUCCESS) {
  -        /* XXX log message */
  -        return 0;
  -    }
  -
  -    buf = apr_pstrcat(r->pool, "X-NAME: ", info->name, "\n", NULL);
  -    amt = strlen(buf);
  -    rc = apr_file_write(fd, buf, &amt);
  -    if(rc != APR_SUCCESS) {
  -        /* XXX log message */
  -        return 0;
  -    }
  -    return 1;
  -}
  -
  -apr_status_t file_cache_el_final(cache_info *info, cache_handle_t *h, request_rec *r)
  -{
  -    disk_cache_conf *conf = ap_get_module_config(r->server->module_config,
  -                                                 &disk_cache_module);
  -
  -    /* move the data over */
  -    if (info->fd) {
  -        apr_file_flush(info->fd);
  -        if (!info->datafile) info->datafile = data_file(h, r->pool, h->cache_obj->key);
 /* by: wsf @A1A */
  -        if (unlink(info->datafile)) /* if we can remove it, we clearly don't have to
build the dirs */
  -            mkdir_structure(info->datafile, conf->cache_root);
  -        else {
  -            /* XXX log */
  -        }
  -        if (link(h->cache_obj->tempfile, info->datafile) == -1) {
  -            /* XXX log */
  -        }
  -        else {
  -            /* XXX log message */
  -        }
  -       if (unlink(h->cache_obj->tempfile) == -1) {
  -           /* XXX log message */
  -       }
  -       else {
  -           /* XXX log message */
  -       }
  -   }
  -   if (info->fd) {
  -       apr_file_close(info->fd);     /* if you finalize, you are done writing, so close
it */
  -       info->fd = 0;
  -       /* XXX log */
  -   }
  -
  -   return APR_SUCCESS;
  -}
  -
   static void *create_config(apr_pool_t *p, server_rec *s)
   {
       disk_cache_conf *conf = apr_pcalloc(p, sizeof(disk_cache_conf));
  @@ -501,7 +600,7 @@
   }
   
   /*
  - * mod_disk_cache configuration directives
  + * mod_disk_cache configuration directives handlers.
    */
   static const char
   *set_cache_root(cmd_parms *parms, void *struct_ptr, char *arg)
  @@ -599,6 +698,7 @@
       /* XXX */
       return NULL;
   }
  +static const char
   *set_cache_maxgcmem(cmd_parms *parms, char *struct_ptr, char *arg)
   {
       disk_cache_conf *conf = ap_get_module_config(parms->server->module_config, 
  
  
  
  1.2       +3 -2      httpd-2.0/modules/experimental/mod_disk_cache.dsp
  
  Index: mod_disk_cache.dsp
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_disk_cache.dsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mod_disk_cache.dsp	3 Feb 2002 06:23:10 -0000	1.1
  +++ mod_disk_cache.dsp	3 Feb 2002 19:04:15 -0000	1.2
  @@ -40,6 +40,7 @@
   # PROP Use_Debug_Libraries 0
   # PROP Output_Dir "Release"
   # PROP Intermediate_Dir "Release"
  +# PROP Ignore_Export_Lib 0
   # PROP Target_Dir ""
   # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS"
/D "_USRDLL" /D "MOD_DISK_CACHE_EXPORTS" /YX /FD /c
   # ADD CPP /nologo /MT /W3 /GX /O2 /I "../../srclib/apr-util/include" /I "../../srclib/apr/include"
/I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MOD_DISK_CACHE_EXPORTS"
/YX /FD /c
  @@ -52,7 +53,7 @@
   # ADD BSC32 /nologo
   LINK32=link.exe
   # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
  -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
  +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/mod_disk_cache.so"
   
   !ELSEIF  "$(CFG)" == "mod_disk_cache - Win32 Debug"
   
  @@ -78,7 +79,7 @@
   # ADD BSC32 /nologo
   LINK32=link.exe
   # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386
/pdbtype:sept
  -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386
/pdbtype:sept
  +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386
/out:"Debug/mod_disk_cache.so" /pdbtype:sept
   
   !ENDIF 
   
  
  
  
  1.16      +1 -1      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- mod_mem_cache.c	3 Feb 2002 06:24:55 -0000	1.15
  +++ mod_mem_cache.c	3 Feb 2002 19:04:15 -0000	1.16
  @@ -311,7 +311,7 @@
       return OK;
   }
   
  -static int open_entity(cache_handle_t *h, apr_pool_t *p, const char *type, const char *key)

  +static int open_entity(cache_handle_t *h, request_rec *r, const char *type, const char
*key) 
   {
       cache_object_t *obj;
   
  
  
  

Mime
View raw message