From c9384d65f6fb5d6c661f9f65c4b60956e7d4bc1a Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 2 Aug 2019 14:38:38 +0100 Subject: curl: Immediately abort fetchers when we can Signed-off-by: Daniel Silverstone --- content/fetchers/curl.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'content') diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index c039429a5..18eba12b0 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -812,23 +812,6 @@ static void fetch_curl_cache_handle(CURL *handle, lwc_string *host) } -/** - * Abort a fetch. - */ -static void fetch_curl_abort(void *vf) -{ - struct curl_fetch_info *f = (struct curl_fetch_info *)vf; - assert(f); - NSLOG(netsurf, INFO, "fetch %p, url '%s'", f, nsurl_access(f->url)); - if (f->curl_handle) { - f->abort = true; - } else { - fetch_remove_from_queues(f->fetch_handle); - fetch_free(f->fetch_handle); - } -} - - /** * Clean up the provided fetch object and free it. * @@ -855,6 +838,30 @@ static void fetch_curl_stop(struct curl_fetch_info *f) } +/** + * Abort a fetch. + */ +static void fetch_curl_abort(void *vf) +{ + struct curl_fetch_info *f = (struct curl_fetch_info *)vf; + assert(f); + NSLOG(netsurf, INFO, "fetch %p, url '%s'", f, nsurl_access(f->url)); + if (f->curl_handle) { + if (inside_curl) { + NSLOG(netsurf, DEBUG, "Deferring cleanup"); + f->abort = true; + } else { + NSLOG(netsurf, DEBUG, "Immediate abort"); + fetch_curl_stop(f); + fetch_free(f->fetch_handle); + } + } else { + fetch_remove_from_queues(f->fetch_handle); + fetch_free(f->fetch_handle); + } +} + + /** * Free a fetch structure and associated resources. */ -- cgit v1.2.3