From 1c42c0569faa469bd6fb5f76069920af6fc1ddd5 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 14 Apr 2010 20:42:03 +0000 Subject: [PATCH] Ensure we invalidate cache data and mark objects as complete on failure to fetch. svn path=/trunk/netsurf/; revision=10402 --- content/llcache.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/content/llcache.c b/content/llcache.c index 4394d186d..930ed5543 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1516,6 +1516,11 @@ nserror llcache_query_handle_response(bool proceed, void *cbpw) if (proceed) return llcache_object_refetch(object); + /* Invalidate cache-control data */ + memset(&object->cache, 0, sizeof(llcache_cache_control)); + /* Mark it complete */ + object->fetch.state = LLCACHE_FETCH_COMPLETE; + /* Inform client(s) that object fetch failed */ event.type = LLCACHE_EVENT_ERROR; /** \todo More appropriate error message */ @@ -1601,6 +1606,7 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, case FETCH_ERROR: /* An error occurred while fetching */ /* The fetch has has already been cleaned up by the fetcher */ + object->fetch.state = LLCACHE_FETCH_COMPLETE; object->fetch.fetch = NULL; /* Invalidate cache control data */ @@ -1639,6 +1645,11 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, if (object->fetch.fetch != NULL) { fetch_abort(object->fetch.fetch); object->fetch.fetch = NULL; + + /* Invalidate cache control data */ + memset(&(object->cache), 0, + sizeof(llcache_cache_control)); + object->fetch.state = LLCACHE_FETCH_COMPLETE; } return; } @@ -1790,13 +1801,15 @@ nserror llcache_fetch_notmodified(llcache_object *object, /* Bring candidate's cache data up to date */ llcache_object_cache_update(object->candidate); - /* Invalidate our cache-control data */ - memset(&object->cache, 0, sizeof(llcache_cache_control)); - /* Ensure fetch has stopped */ fetch_abort(object->fetch.fetch); object->fetch.fetch = NULL; + /* Invalidate our cache-control data */ + memset(&object->cache, 0, sizeof(llcache_cache_control)); + /* Mark it complete */ + object->fetch.state = LLCACHE_FETCH_COMPLETE; + /* Candidate is now our object */ *replacement = object->candidate; @@ -2083,6 +2096,11 @@ nserror llcache_fetch_auth(llcache_object *object, const char *realm) } else { llcache_event event; + /* Invalidate cache-control data */ + memset(&object->cache, 0, sizeof(llcache_cache_control)); + /* Mark it complete */ + object->fetch.state = LLCACHE_FETCH_COMPLETE; + /* Inform client(s) that object fetch failed */ event.type = LLCACHE_EVENT_ERROR; /** \todo More appropriate error message */ @@ -2125,6 +2143,11 @@ nserror llcache_fetch_cert_error(llcache_object *object, } else { llcache_event event; + /* Invalidate cache-control data */ + memset(&object->cache, 0, sizeof(llcache_cache_control)); + /* Mark it complete */ + object->fetch.state = LLCACHE_FETCH_COMPLETE; + /* Inform client(s) that object fetch failed */ event.type = LLCACHE_EVENT_ERROR; /** \todo More appropriate error message */