summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-10-28 23:50:01 +0000
committerVincent Sanders <vince@kyllikki.org>2019-10-28 23:50:01 +0000
commit1176ce427113face73c48c4b2e4e5a810577b355 (patch)
treec8fadcd0c54cc99532f0c406f4f75178e2e00cf7
parent5aeca580f43c5866794a630e35fa18dbfeefaa01 (diff)
downloadnetsurf-1176ce427113face73c48c4b2e4e5a810577b355.tar.gz
netsurf-1176ce427113face73c48c4b2e4e5a810577b355.tar.bz2
Improve timeout error messaging
-rw-r--r--content/llcache.c61
-rw-r--r--resources/FatMessages1
-rw-r--r--utils/errors.h1
-rw-r--r--utils/messages.c4
4 files changed, 58 insertions, 9 deletions
diff --git a/content/llcache.c b/content/llcache.c
index f209fabf0..cd4066210 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -2354,6 +2354,7 @@ static nserror llcache_fetch_cert_error(llcache_object *object)
return error;
}
+
/**
* Handle a TLS connection setup failure
*
@@ -2376,7 +2377,7 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
/* Make no attempt to downgrade if HSTS is in use
* (i.e. assume server does TLS properly) */
if (object->fetch.hsts_in_use ||
- object->fetch.tried_with_tls_downgrade) {
+ object->fetch.tried_with_tls_downgrade) {
/* Have already tried to downgrade, so give up */
llcache_event event;
@@ -2400,6 +2401,46 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
return error;
}
+
+/**
+ * handle time out while trying to fetch.
+ *
+ * \param object Object being fetched
+ * \return NSERROR_OK on success otherwise error code
+ */
+static nserror llcache_fetch_timeout(llcache_object *object)
+{
+ llcache_event event;
+
+ /* The fetch has already been cleaned up by the fetcher but
+ * we would like to retry if we can.
+ */
+ if (object->fetch.retries_remaining > 1) {
+ object->fetch.retries_remaining--;
+ return llcache_object_refetch(object);
+ }
+
+ /* The fetch has has already been cleaned up by the fetcher */
+ object->fetch.state = LLCACHE_FETCH_COMPLETE;
+ object->fetch.fetch = NULL;
+
+ /* Release candidate, if any */
+ if (object->candidate != NULL) {
+ object->candidate->candidate_count--;
+ object->candidate = NULL;
+ }
+
+ /* Invalidate cache control data */
+ llcache_invalidate_cache_control_data(object);
+
+ event.type = LLCACHE_EVENT_ERROR;
+ event.data.error.code = NSERROR_TIMEOUT;
+ event.data.error.msg = NULL;
+
+ return llcache_send_event_to_users(object, &event);
+}
+
+
/**
* Construct a sorted list of objects available for writeout operation.
*
@@ -2732,6 +2773,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
error = llcache_fetch_redirect(object,
msg->data.redirect, &object);
break;
+
case FETCH_NOTMODIFIED:
/* Conditional request determined that cached object is fresh */
error = llcache_fetch_notmodified(object, &object);
@@ -2744,6 +2786,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
+
case FETCH_FINISHED:
/* Finished fetching */
{
@@ -2775,14 +2818,9 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
/* Out-of-band information */
case FETCH_TIMEDOUT:
/* Timed out while trying to fetch. */
- /* The fetch has already been cleaned up by the fetcher but
- * we would like to retry if we can. */
- if (object->fetch.retries_remaining > 1) {
- object->fetch.retries_remaining--;
- error = llcache_object_refetch(object);
- break;
- }
- /* Fall through */
+ error = llcache_fetch_timeout(object);
+ break;
+
case FETCH_ERROR:
/* An error occurred while fetching */
/* The fetch has has already been cleaned up by the fetcher */
@@ -2807,6 +2845,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
error = llcache_send_event_to_users(object, &event);
break;
+
case FETCH_PROGRESS:
/* Progress update */
event.type = LLCACHE_EVENT_PROGRESS;
@@ -2815,6 +2854,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
error = llcache_send_event_to_users(object, &event);
break;
+
case FETCH_CERTS:
/* Certificate information from the fetch */
/** \todo CERTS - Should we persist this on the object and
@@ -2826,6 +2866,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
error = llcache_send_event_to_users(object, &event);
break;
+
/* Events requiring action */
case FETCH_AUTH:
/* Need Authentication */
@@ -2838,6 +2879,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
error = llcache_fetch_auth(object, msg->data.auth.realm);
break;
+
case FETCH_CERT_ERR:
/* Something went wrong when validating TLS certificates */
@@ -2849,6 +2891,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
error = llcache_fetch_cert_error(object);
break;
+
case FETCH_SSL_ERR:
/* TLS connection setup failed */
diff --git a/resources/FatMessages b/resources/FatMessages
index 12d81bd5e..d1ecd9dd1 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -459,6 +459,7 @@ de.all.DirectoryError:Verzeichnis '%s' existiert bereits.
fr.all.DirectoryError:répertoire '%s' existe déjà
it.all.DirectoryError:La directory '%s' è già esistente
nl.all.DirectoryError:map '%s' bestaat reeds
+en.all.Timeout:This site took too long to respond
# error messages for RISC OS
#
diff --git a/utils/errors.h b/utils/errors.h
index a54351530..ac4d38e2b 100644
--- a/utils/errors.h
+++ b/utils/errors.h
@@ -62,6 +62,7 @@ typedef enum {
NSERROR_BAD_REDIRECT, /**< Fetch encountered a bad redirect */
NSERROR_BAD_AUTH, /**< Fetch needs authentication data */
NSERROR_BAD_CERTS, /**< Fetch needs certificate chain check */
+ NSERROR_TIMEOUT, /**< Operation timed out */
} nserror;
#endif
diff --git a/utils/messages.c b/utils/messages.c
index 0d2085c08..197d45ea6 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -333,6 +333,10 @@ const char *messages_get_errorcode(nserror code)
case NSERROR_BAD_CERTS:
/* Certificate chain verification failure */
return messages_get_ctx("CertificateVerificationNeeded", messages_hash);
+
+ case NSERROR_TIMEOUT:
+ /* Operation timed out */
+ return messages_get_ctx("Timeout", messages_hash);
}
/* The switch has no default, so the compiler should tell us when we