httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r462601 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_disk_cache.c
Date Tue, 10 Oct 2006 22:10:02 GMT
Author: minfrin
Date: Tue Oct 10 15:10:01 2006
New Revision: 462601

URL: http://svn.apache.org/viewvc?view=rev&rev=462601
Log:
mod_disk_cache: NULL fd pointers when closing them, fix missing
close/flush, remove some unneccessary code duplication instead
of calling the right helper in replace_brigade_with_cache().

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/cache/mod_disk_cache.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?view=diff&rev=462601&r1=462600&r2=462601
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Oct 10 15:10:01 2006
@@ -2,6 +2,11 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_disk_cache: NULL fd pointers when closing them, fix missing
+     close/flush, remove some unneccessary code duplication instead
+     of calling the right helper in replace_brigade_with_cache().
+     [Niklas Edmundsson <nikke acc.umu.se>]
+
   *) sendfile_nonblocking() takes the _brigade_ as an argument, gets 
      the first bucket from the brigade, finds it not to be a FILE
      bucket and barfs. The fix is to pass a bucket rather than a brigade.

Modified: httpd/httpd/trunk/modules/cache/mod_disk_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_disk_cache.c?view=diff&rev=462601&r1=462600&r2=462601
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_disk_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_disk_cache.c Tue Oct 10 15:10:01 2006
@@ -445,6 +445,7 @@
     while(1) {
         if(dobj->hfd) {
             apr_file_close(dobj->hfd);
+            dobj->hfd = NULL;
         }
         rc = open_header(h, r, key, conf);
         if(rc != APR_SUCCESS && rc != CACHE_ENODATA) {
@@ -978,6 +979,7 @@
     }
 
     apr_file_close(dobj->hfd);
+    dobj->hfd = NULL;
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "disk_cache: Recalled headers for URL %s",  dobj->name);
@@ -1308,6 +1310,7 @@
             rv = apr_file_open(&dobj->hfd, dobj->hdrsfile, 
                     APR_WRITE | APR_BINARY | APR_BUFFERED, 0, r->pool);
             if (rv != APR_SUCCESS) {
+                dobj->hfd = NULL;
                 return rv;
             }
         }
@@ -1342,6 +1345,19 @@
         return rv;
     }
 
+    /* If the body size is unknown, the header file will be rewritten later
+       so we can't close it */
+    if(dobj->initial_size < 0) {
+        rv = apr_file_flush(dobj->hfd);
+    }
+    else {
+        rv = apr_file_close(dobj->hfd);
+        dobj->hfd = NULL;
+    }
+    if(rv != APR_SUCCESS) {
+        return rv;
+    }
+
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "disk_cache: Stored headers for URL %s",  dobj->name);
     return APR_SUCCESS;
@@ -1418,23 +1434,20 @@
                                                apr_bucket_brigade *bb)
 {
     apr_status_t rv;
-    int flags;
     apr_bucket *e;
-    core_dir_config *pdcfg = ap_get_module_config(r->per_dir_config,
-            &core_module);
     disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
 
-    flags = APR_READ|APR_BINARY;
-#if APR_HAS_SENDFILE
-    flags |= ((pdcfg->enable_sendfile == ENABLE_SENDFILE_OFF)
-            ? 0 : APR_SENDFILE_ENABLED);
-#endif
-
-    rv = apr_file_open(&dobj->fd, dobj->datafile, flags, 0, r->pool);
+    if(dobj->fd) {
+        apr_file_close(dobj->fd);
+        dobj->fd = NULL;
+    }
+    rv = open_body_timeout(r, dobj->name, dobj);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
-                     "disk_cache: Error opening datafile %s for URL %s",
-                     dobj->datafile, dobj->name);
+        if(rv != CACHE_EDECLINED) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+                         "disk_cache: Error opening datafile %s for URL %s",
+                         dobj->datafile, dobj->name);
+        }
         return rv;
     }
 
@@ -1664,13 +1677,11 @@
 
     /* All checks were fine, close output file */
     rv = apr_file_close(dobj->fd);
+    dobj->fd = NULL;
     if(rv != APR_SUCCESS) {
         file_cache_errorcleanup(dobj, r);
         return rv;
     }
-
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                 "disk_cache: Body for URL %s cached.",  dobj->name);
 
     /* Redirect to cachefile if we copied a plain file */
     if(copy_file) {



Mime
View raw message