]> granicus.if.org Git - apache/commitdiff
Fix the error cases in the cache_select() loop. On error we must loop around
authorGraham Leggett <minfrin@apache.org>
Sun, 17 Oct 2010 00:01:45 +0000 (00:01 +0000)
committerGraham Leggett <minfrin@apache.org>
Sun, 17 Oct 2010 00:01:45 +0000 (00:01 +0000)
to the next provider, not return DECLINED too early, except for the
revalidate case, where returning DECLINED is correct behaviour.

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

modules/cache/cache_storage.c

index fc5cc465c67cf080a32ea34352340476178613eb..32105836ab17f98d32f8cbc5efdc450fbf064113 100644 (file)
@@ -229,11 +229,12 @@ int cache_select(cache_request_rec *cache, request_rec *r)
         switch ((rv = list->provider->open_entity(h, r, cache->key))) {
         case OK: {
             char *vary = NULL;
-            int fresh;
+            int fresh, mismatch = 0;
 
             if (list->provider->recall_headers(h, r) != APR_SUCCESS) {
-                /* TODO: Handle this error */
-                return DECLINED;
+                /* try again with next cache type */
+                list = list->next;
+                continue;
             }
 
             /*
@@ -284,10 +285,17 @@ int cache_select(cache_request_rec *cache, request_rec *r)
                     ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS,
                                 r->server,
                                 "cache_select_url(): Vary header mismatch.");
-                    return DECLINED;
+                    mismatch = 1;
                 }
             }
 
+            /* no vary match, try next provider */
+            if (mismatch) {
+                /* try again with next cache type */
+                list = list->next;
+                continue;
+            }
+
             cache->provider = list->provider;
             cache->provider_name = list->provider_name;
 
@@ -337,6 +345,9 @@ int cache_select(cache_request_rec *cache, request_rec *r)
                                       lastmod);
                     }
                     cache->stale_handle = h;
+
+                    /* ready to revalidate, pretend we were never here */
+                    return DECLINED;
                 }
                 else {
                     int irv;
@@ -351,9 +362,12 @@ int cache_select(cache_request_rec *cache, request_rec *r)
                         ap_log_error(APLOG_MARK, APLOG_DEBUG, irv, r->server,
                                      "cache: attempt to remove url from cache unsuccessful.");
                     }
+
+                    /* try again with next cache type */
+                    list = list->next;
+                    continue;
                 }
 
-                return DECLINED;
             }
 
             /* Okay, this response looks okay.  Merge in our stuff and go. */