You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2001/05/11 19:34:26 UTC

cvs commit: httpd-2.0/modules/cache mod_file_cache.c

stoddard    01/05/11 10:34:25

  Modified:    modules/cache mod_file_cache.c
  Log:
  Do not send apr_file_t allocated out of the pconf pool down the
  filter chain.  This is not perfect but better. Need to do some
  more work in apr_os_file_put to initialize fields a bit better.
  
  Revision  Changes    Path
  1.54      +10 -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.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- mod_file_cache.c	2001/03/31 11:51:16	1.53
  +++ mod_file_cache.c	2001/05/11 17:34:17	1.54
  @@ -328,6 +328,8 @@
   #if APR_HAS_SENDFILE
       apr_size_t nbytes;
       apr_status_t rv = APR_EINIT;
  +    apr_file_t *rfile;
  +    apr_os_file_t fd;
   
       /* A cached file handle (more importantly, its file pointer) is 
        * shared by all threads in the process. The file pointer will 
  @@ -350,8 +352,14 @@
               return DECLINED;
       }
   
  -
  -    rv = ap_send_fd(file->file, r, 0, file->finfo.size, &nbytes);
  +    /* Create an apr_file_t anchored out of the request pool to use 
  +     * on the call to ap_send_fd(). The cached apr_file_t is allocated 
  +     * out of pconf (a life of the server pool) and sending it down
  +     * the filter chain could cause memory leaks.
  +     */
  +    apr_os_file_get(&fd, file->file);
  +    apr_os_file_put(&rfile, &fd, r->pool);
  +    rv = ap_send_fd(rfile, r, 0, file->finfo.size, &nbytes);
       if (rv != APR_SUCCESS) {
           /* ap_send_fd will log the error */
           return HTTP_INTERNAL_SERVER_ERROR;