]> granicus.if.org Git - apache/commitdiff
mod_cache: try to use the key of a possible open but stale cache entry
authorJan Kaluža <jkaluza@apache.org>
Mon, 26 May 2014 09:15:44 +0000 (09:15 +0000)
committerJan Kaluža <jkaluza@apache.org>
Mon, 26 May 2014 09:15:44 +0000 (09:15 +0000)
if we have one in cache_try_lock(). PR 50317

Submitted by: Ruediger Pluem

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

modules/cache/cache_util.c

index bf45093192747ed1947fc817abc1dcffd005fcf5..3cff6f69e87d63c713547d8c4f67a6a3b0a7ad1f 100644 (file)
@@ -284,7 +284,25 @@ apr_status_t cache_try_lock(cache_server_conf *conf, cache_request_rec *cache,
 
     /* create the key if it doesn't exist */
     if (!cache->key) {
-        cache_generate_key(r, r->pool, &cache->key);
+        cache_handle_t *h;
+        /*
+         * Try to use the key of a possible open but stale cache
+         * entry if we have one.
+         */
+        if (cache->handle != NULL) {
+            h = cache->handle;
+        }
+        else {
+            h = cache->stale_handle;
+        }
+        if ((h != NULL) &&
+            (h->cache_obj != NULL) &&
+            (h->cache_obj->key != NULL)) {
+            cache->key = apr_pstrdup(r->pool, h->cache_obj->key);
+        }
+        else {
+            cache_generate_key(r, r->pool, &cache->key);
+        }
     }
 
     /* create a hashed filename from the key, and save it for later */