From 60b5039c339d5d06d16d27f4a241b56aee7284c8 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 3 Mar 2011 00:40:50 +0000 Subject: Protect against object being cleaned while waiting for a query response svn path=/trunk/netsurf/; revision=11894 --- content/llcache.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/content/llcache.c b/content/llcache.c index c398620c0..1deb8cae9 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -84,6 +84,8 @@ typedef struct { uint32_t redirect_count; /**< Count of redirects followed */ bool tried_with_auth; /**< Whether we've tried with auth */ + + bool outstanding_query; /**< Waiting for a query response */ } llcache_fetch_ctx; typedef enum { @@ -1634,7 +1636,8 @@ nserror llcache_clean(void) /* The candidate count of uncacheable objects is always 0 */ if (object->users == NULL && object->candidate_count == 0 && - object->fetch.fetch == NULL) { + object->fetch.fetch == NULL && + object->fetch.outstanding_query == false) { #ifdef LLCACHE_TRACE LOG(("Found victim %p", object)); #endif @@ -1652,7 +1655,8 @@ nserror llcache_clean(void) if (object->users == NULL && object->candidate_count == 0 && llcache_object_is_fresh(object) == false && - object->fetch.fetch == NULL) { + object->fetch.fetch == NULL && + object->fetch.outstanding_query == false) { #ifdef LLCACHE_TRACE LOG(("Found victim %p", object)); #endif @@ -1673,7 +1677,9 @@ nserror llcache_clean(void) if (object->users == NULL && object->candidate_count == 0 && - object->fetch.fetch == NULL) { + object->fetch.fetch == NULL && + object->fetch.outstanding_query == + false) { #ifdef LLCACHE_TRACE LOG(("Found victim %p", object)); #endif @@ -1747,6 +1753,8 @@ nserror llcache_query_handle_response(bool proceed, void *cbpw) llcache_event event; llcache_object *object = cbpw; + object->fetch.outstanding_query = false; + /* Refetch, using existing fetch parameters, if client allows us to */ if (proceed) return llcache_object_refetch(object); @@ -2451,6 +2459,8 @@ nserror llcache_fetch_auth(llcache_object *object, const char *realm) query.url = object->url; query.data.auth.realm = realm; + object->fetch.outstanding_query = true; + error = query_cb(&query, query_cb_pw, llcache_query_handle_response, object); } else { @@ -2504,6 +2514,8 @@ nserror llcache_fetch_cert_error(llcache_object *object, query.data.ssl.certs = certs; query.data.ssl.num = num; + object->fetch.outstanding_query = true; + error = query_cb(&query, query_cb_pw, llcache_query_handle_response, object); } else { -- cgit v1.2.3