]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Reintroduce an optimisation lost in some cut and paste. The cache lock
authorGraham Leggett <minfrin@apache.org>
Wed, 26 Aug 2009 23:22:18 +0000 (23:22 +0000)
committerGraham Leggett <minfrin@apache.org>
Wed, 26 Aug 2009 23:22:18 +0000 (23:22 +0000)
is removed as soon as we see an EOS, or is removed immediately if a
failure has occurred.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@808220 13f79535-47bb-0310-9956-ffa450edef68

modules/cache/cache_util.c
modules/cache/mod_cache.c

index 3b70af29ae7a8847bf4ecbfe6d41f0810921996b..e287553ccd60a84a86c43c75acd8891a892bb630 100644 (file)
@@ -168,7 +168,7 @@ CACHE_DECLARE(apr_int64_t) ap_cache_current_age(cache_info *info,
  * Try obtain a cache wide lock on the given cache key.
  *
  * If we return APR_SUCCESS, we obtained the lock, and we are clear to
- * proceed to the backend. If we return APR_EEXISTS, the the lock is
+ * proceed to the backend. If we return APR_EEXISTS, then the lock is
  * already locked, someone else has gone to refresh the backend data
  * already, so we must return stale data with a warning in the mean
  * time. If we return anything else, then something has gone pear
@@ -177,7 +177,7 @@ CACHE_DECLARE(apr_int64_t) ap_cache_current_age(cache_info *info,
  * This lock is created from the request pool, meaning that should
  * something go wrong and the lock isn't deleted on return of the
  * request headers from the backend for whatever reason, at worst the
- * lock will be cleaned up when the request is dies or finishes.
+ * lock will be cleaned up when the request dies or finishes.
  *
  * If something goes truly bananas and the lock isn't deleted when the
  * request dies, the lock will be trashed when its max-age is reached,
index e0d6f5547fd09ad996627a54870d9805b422bdbf..b5e616b69c24927a60b1e63f34c6aff2a916856a 100644 (file)
@@ -393,19 +393,14 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
 
             /* give someone else the chance to cache the file */
             ap_cache_remove_lock(conf, r, cache->handle ?
-                    (char *)cache->handle->cache_obj->key : NULL, in);
+                    (char *)cache->handle->cache_obj->key : NULL, NULL);
         }
+        else {
+
+               /* proactively remove the lock as soon as we see the eos bucket */
+            ap_cache_remove_lock(conf, r, cache->handle ?
+                    (char *)cache->handle->cache_obj->key : NULL, in);
 
-        /* proactively remove the lock as soon as we see the eos bucket */
-        for (e = APR_BRIGADE_FIRST(in);
-             e != APR_BRIGADE_SENTINEL(in);
-             e = APR_BUCKET_NEXT(e))
-        {
-            if (APR_BUCKET_IS_EOS(e)) {
-                ap_cache_remove_lock(conf, r, cache->handle ?
-                        (char *)cache->handle->cache_obj->key : NULL, in);
-                break;
-            }
         }
 
         return ap_pass_brigade(f->next, in);
@@ -595,7 +590,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
 
         /* remove the lock file unconditionally */
         ap_cache_remove_lock(conf, r, cache->handle ?
-                (char *)cache->handle->cache_obj->key : NULL, in);
+                (char *)cache->handle->cache_obj->key : NULL, NULL);
 
         /* ship the data up the stack */
         return ap_pass_brigade(f->next, in);
@@ -698,7 +693,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
         /* Caching layer declined the opportunity to cache the response */
         ap_remove_output_filter(f);
         ap_cache_remove_lock(conf, r, cache->handle ?
-                (char *)cache->handle->cache_obj->key : NULL, in);
+                (char *)cache->handle->cache_obj->key : NULL, NULL);
         return ap_pass_brigade(f->next, in);
     }
 
@@ -894,7 +889,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
 
         /* let someone else attempt to cache */
         ap_cache_remove_lock(conf, r, cache->handle ?
-                (char *)cache->handle->cache_obj->key : NULL, in);
+                (char *)cache->handle->cache_obj->key : NULL, NULL);
 
         return ap_pass_brigade(f->next, bb);
     }
@@ -905,7 +900,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
 
         ap_remove_output_filter(f);
         ap_cache_remove_lock(conf, r, cache->handle ?
-                (char *)cache->handle->cache_obj->key : NULL, in);
+                (char *)cache->handle->cache_obj->key : NULL, NULL);
         return ap_pass_brigade(f->next, in);
     }
 
@@ -915,21 +910,13 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
                      "cache: store_body failed");
         ap_remove_output_filter(f);
         ap_cache_remove_lock(conf, r, cache->handle ?
-                (char *)cache->handle->cache_obj->key : NULL, in);
+                (char *)cache->handle->cache_obj->key : NULL, NULL);
         return ap_pass_brigade(f->next, in);
     }
 
     /* proactively remove the lock as soon as we see the eos bucket */
-    for (e = APR_BRIGADE_FIRST(in);
-         e != APR_BRIGADE_SENTINEL(in);
-         e = APR_BUCKET_NEXT(e))
-    {
-        if (APR_BUCKET_IS_EOS(e)) {
-            ap_cache_remove_lock(conf, r, cache->handle ?
-                    (char *)cache->handle->cache_obj->key : NULL, in);
-            break;
-        }
-    }
+    ap_cache_remove_lock(conf, r, cache->handle ?
+            (char *)cache->handle->cache_obj->key : NULL, in);
 
     return ap_pass_brigade(f->next, in);
 }