summaryrefslogtreecommitdiff
path: root/content/fetchers
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-02 14:38:38 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-02 14:38:54 +0100
commitc9384d65f6fb5d6c661f9f65c4b60956e7d4bc1a (patch)
treebfbb63f0ef83354ffa2272460ed8edc0923945ae /content/fetchers
parent0eb5aa68fbb321477c7e6e0b0452bf1a4186fd99 (diff)
downloadnetsurf-c9384d65f6fb5d6c661f9f65c4b60956e7d4bc1a.tar.gz
netsurf-c9384d65f6fb5d6c661f9f65c4b60956e7d4bc1a.tar.bz2
curl: Immediately abort fetchers when we can
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/fetchers')
-rw-r--r--content/fetchers/curl.c41
1 files changed, 24 insertions, 17 deletions
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
@@ -813,23 +813,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.
*
* Will prod the queue afterwards to allow pending requests to be initiated.
@@ -856,6 +839,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.
*/
static void fetch_curl_free(void *vf)