From 516dcb96e111c6e1e0c1503ac156497aa15894d6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 2 Jul 2014 14:50:23 +0100 Subject: fix unhelpful assert at quit --- content/fetch.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'content/fetch.c') diff --git a/content/fetch.c b/content/fetch.c index 3d1183aa0..abfdf4c97 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -290,9 +290,28 @@ void fetcher_quit(void) { int fetcherd; /* fetcher index */ for (fetcherd = 0; fetcherd < MAX_FETCHERS; fetcherd++) { - if (fetchers[fetcherd].refcount > 0) { - /* assert if the fetcher is active at quit */ - assert(fetchers[fetcherd].refcount == 1); + if (fetchers[fetcherd].refcount > 1) { + /* fetcher still has reference at quit. This + * should not happen as the fetch should have + * been aborted in llcache shutdown. + * + * This appears to be normal behaviour if a + * curl operation is still in progress at exit + * as the abort waits for curl to complete. + * + * We could make the user wait for curl to + * complete but we are exiting anyway so thats + * unhelpful. Instead we just log it and force + * the reference count to allow the fetcher to + * be stopped. + */ + LOG(("Fetcher for scheme %s still has %d active users at quit.", + lwc_string_data(fetchers->scheme_name), + fetchers->refcount)); + + fetchers->refcount = 1; + } + if (fetchers[fetcherd].refcount == 1) { fetch_unref_fetcher(fetcherd); } -- cgit v1.2.3