mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-24 18:34:27 +03:00
fetch: Automatically handle fetches which fail to finish
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
50ff8433da
commit
083ba385d7
@ -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);
|
||||
}
|
||||
|
||||
|
@ -39,19 +39,27 @@ struct ssl_cert_info;
|
||||
*/
|
||||
typedef enum {
|
||||
FETCH_PROGRESS,
|
||||
FETCH_CERTS,
|
||||
FETCH_HEADER,
|
||||
FETCH_DATA,
|
||||
/* Anything after here is a completed fetch of some kind. */
|
||||
FETCH_FINISHED,
|
||||
FETCH_TIMEDOUT,
|
||||
FETCH_ERROR,
|
||||
FETCH_REDIRECT,
|
||||
FETCH_NOTMODIFIED,
|
||||
FETCH_CERTS,
|
||||
FETCH_AUTH,
|
||||
FETCH_CERT_ERR,
|
||||
FETCH_SSL_ERR
|
||||
} fetch_msg_type;
|
||||
|
||||
/** Minimum finished message type.
|
||||
*
|
||||
* If a fetch does not progress this far, it's an error and the fetch machinery
|
||||
* will send FETCH_ERROR to the llcache on fetch_free()
|
||||
*/
|
||||
#define FETCH_MIN_FINISHED_MSG FETCH_FINISHED
|
||||
|
||||
/**
|
||||
* Fetcher message data
|
||||
*/
|
||||
|
@ -1133,6 +1133,9 @@ it.all.FetchErrorTitle:Errore durante il recupero della pagina
|
||||
en.all.FetchErrorDescription:An error occurred when connecting to %s
|
||||
it.all.FetchErrorDescription:Si è verificato un errore durante la connessione a %s
|
||||
|
||||
# Generic fetcher failure (really a programming error)
|
||||
en.all.FetchFailedToFinish:The fetcher for this request failed to complete
|
||||
|
||||
|
||||
# SSL certificate viewer
|
||||
# ======================
|
||||
|
Loading…
x
Reference in New Issue
Block a user