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/cache mod_file_cache.c
Date Fri, 23 Feb 2001 18:57:36 GMT
stoddard    01/02/23 10:57:36

  Modified:    .        CHANGES
               modules/cache mod_file_cache.c
  Log:
  Modify mod_file_cache to save pre-formatted strings for
  content-length and last-modified headers for performance.
  
  Submitted by:  Mike Abbot <mja@trudge.engr.sgi.com>
  Reviewed by: Bill Stoddard
  
  Revision  Changes    Path
  1.109     +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- CHANGES	2001/02/23 00:50:22	1.108
  +++ CHANGES	2001/02/23 18:57:35	1.109
  @@ -1,5 +1,9 @@
   Changes with Apache 2.0.12-dev
   
  +  *) Modify mod_file_cache to save pre-formatted strings for 
  +     content-length and last-modified headers for performance. 
  +     [Mike Abbot <mja@trudge.engr.sgi.com>]
  +
     *) Namespace protect IOBUFSIZ since it is exposed in the API.
        [Jon Travis <jtravis@covalent.net>]
   
  
  
  
  1.47      +31 -2     httpd-2.0/modules/cache/mod_file_cache.c
  
  Index: mod_file_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/cache/mod_file_cache.c,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- mod_file_cache.c	2001/02/16 04:26:34	1.46
  +++ mod_file_cache.c	2001/02/23 18:57:36	1.47
  @@ -138,6 +138,8 @@
   #if APR_HAS_MMAP
       apr_mmap_t *mm;
   #endif
  +    char mtimestr[APR_RFC822_DATE_LEN];
  +    char sizestr[21];	/* big enough to hold any 64-bit file size + null */ 
   } a_file;
   
   typedef struct {
  @@ -216,6 +218,8 @@
       }
       tmp.file = fd;
       tmp.filename = apr_pstrdup(cmd->pool, filename);
  +    apr_rfc822_date(tmp.mtimestr, tmp.finfo.mtime);
  +    apr_snprintf(tmp.sizestr, sizeof tmp.sizestr, "%lu", tmp.finfo.size);
       sconf = ap_get_module_config(cmd->server->module_config, &file_cache_module);
       new_file = apr_array_push(sconf->files);
       *new_file = tmp;
  @@ -272,6 +276,8 @@
       }
       apr_file_close(fd);
       tmp.filename = fspec;
  +    apr_rfc822_date(tmp.mtimestr, tmp.finfo.mtime);
  +    apr_snprintf(tmp.sizestr, sizeof tmp.sizestr, "%lu", tmp.finfo.size);
       sconf = ap_get_module_config(cmd->server->module_config, &file_cache_module);
       new_file = apr_array_push(sconf->files);
       *new_file = tmp;
  @@ -432,12 +438,35 @@
           return errstatus;
   
       ap_update_mtime(r, match->finfo.mtime);
  -    ap_set_last_modified(r);
  +
  +    /* ap_set_last_modified() always converts the file mtime to a string
  +     * which is slow.  Accelerate the common case.
  +     * ap_set_last_modified(r);
  +     */
  +    {
  +        apr_time_t mod_time;
  +        char *datestr;
  +
  +        mod_time = ap_rationalize_mtime(r, r->mtime);
  +        if (mod_time == match->finfo.mtime)
  +            datestr = match->mtimestr;
  +        else {
  +            datestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
  +            apr_rfc822_date(datestr, mod_time);
  +        }
  +        apr_table_setn(r->headers_out, "Last-Modified", datestr);
  +    }
  +
       ap_set_etag(r);
       if ((errstatus = ap_meets_conditions(r)) != OK) {
          return errstatus;
       }
  -    ap_set_content_length(r, match->finfo.size);
  +
  +    /* ap_set_content_length() always converts the same number and never
  +     * returns an error.  Accelerate it.
  +     */
  +    r->clength = match->finfo.size;
  +    apr_table_setn(r->headers_out, "Content-Length", match->sizestr);
   
       ap_send_http_header(r);
   
  
  
  

Mime
View raw message