From a7dd7520463061db6ddc4cc6ec898fd8b5a8ba4e Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 16 Sep 2010 22:04:06 +0000 Subject: Ensure that candidate count is reduced if a conditional request results in a non-304 response svn path=/trunk/netsurf/; revision=10791 --- content/llcache.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/content/llcache.c b/content/llcache.c index 940127e1e..c56db13e3 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1653,6 +1653,13 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, /* 3xx responses */ case FETCH_REDIRECT: /* Request resulted in a redirect */ + + /* Release candidate, if any */ + if (object->candidate != NULL) { + object->candidate->candidate_count--; + object->candidate = NULL; + } + error = llcache_fetch_redirect(object, data, &object); break; case FETCH_NOTMODIFIED: @@ -1665,6 +1672,12 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, /* Received a fetch header */ object->fetch.state = LLCACHE_FETCH_HEADERS; + /* Release candidate, if any */ + if (object->candidate != NULL) { + object->candidate->candidate_count--; + object->candidate = NULL; + } + error = llcache_fetch_process_header(object, data, size); break; case FETCH_DATA: @@ -1725,6 +1738,12 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, object->fetch.state = LLCACHE_FETCH_COMPLETE; object->fetch.fetch = NULL; + /* Release candidate, if any */ + if (object->candidate != NULL) { + object->candidate->candidate_count--; + object->candidate = NULL; + } + /* Invalidate cache control data */ llcache_invalidate_cache_control_data(object); @@ -1748,10 +1767,24 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, /* Events requiring action */ case FETCH_AUTH: /* Need Authentication */ + + /* Release candidate, if any */ + if (object->candidate != NULL) { + object->candidate->candidate_count--; + object->candidate = NULL; + } + error = llcache_fetch_auth(object, data); break; case FETCH_CERT_ERR: /* Something went wrong when validating TLS certificates */ + + /* Release candidate, if any */ + if (object->candidate != NULL) { + object->candidate->candidate_count--; + object->candidate = NULL; + } + error = llcache_fetch_cert_error(object, data, size); break; } @@ -1930,6 +1963,7 @@ nserror llcache_fetch_notmodified(llcache_object *object, /* Candidate is now our object */ *replacement = object->candidate; + object->candidate = NULL; /* Old object will be flushed from the cache on the next poll */ -- cgit v1.2.3