summaryrefslogtreecommitdiff
path: root/content/fetch.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-02-24 09:47:52 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-02-24 09:47:52 +0000
commit083ba385d70a6fbc0c89ffbc42f66d035a856139 (patch)
tree1c13f9cb9d1299353edd8314d24423495fb70008 /content/fetch.c
parent50ff8433da5aa19c70459e5370cc1744917a9000 (diff)
downloadnetsurf-083ba385d70a6fbc0c89ffbc42f66d035a856139.tar.gz
netsurf-083ba385d70a6fbc0c89ffbc42f66d035a856139.tar.bz2
fetch: Automatically handle fetches which fail to finish
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/fetch.c')
-rw-r--r--content/fetch.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/content/fetch.c b/content/fetch.c
index 2ac86a812..94654fc6b 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -98,6 +98,7 @@ struct fetch {
int fetcherd; /**< Fetcher descriptor for this fetch */
void *fetcher_handle; /**< The handle for the fetcher. */
bool fetch_is_active; /**< This fetch is active. */
+ fetch_msg_type last_msg;/**< The last message sent for this fetch */
struct fetch *r_prev; /**< Previous active fetch in ::fetch_ring. */
struct fetch *r_next; /**< Next active fetch in ::fetch_ring. */
};
@@ -593,6 +594,20 @@ void fetch_abort(struct fetch *f)
/* exported interface documented in content/fetch.h */
void fetch_free(struct fetch *f)
{
+ if (f->last_msg < FETCH_MIN_FINISHED_MSG) {
+ /* We didn't finish, so tell our user that an error occurred */
+ fetch_msg msg;
+
+ msg.type = FETCH_ERROR;
+ msg.data.error = "FetchFailedToFinish";
+
+ NSLOG(fetch, CRITICAL,
+ "During the fetch of %s, the fetcher did not finish.",
+ nsurl_access(f->url));
+
+ fetch_send_callback(&msg, f);
+ }
+
NSLOG(fetch, DEBUG,
"Freeing fetch %p, fetcher %p",
f,
@@ -788,6 +803,7 @@ fetch_multipart_data_new_kv(struct fetch_multipart_data **list,
void
fetch_send_callback(const fetch_msg *msg, struct fetch *fetch)
{
+ fetch->last_msg = msg->type;
fetch->callback(msg, fetch->p);
}