summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2022-02-12 08:13:28 +0100
committerLars-Dominik Braun <lars@6xq.net>2022-02-12 08:13:28 +0100
commit64f10c268ccb4213a3d1a18c18df1a350f163b2f (patch)
tree719a0b90b792ed3280a737f227670afc64ca8f90 /src
parent69e495c9ac70c1c635a9ae3ce6d4461f9bbba0d1 (diff)
downloadpianobar-64f10c268ccb4213a3d1a18c18df1a350f163b2f.tar.gz
pianobar-64f10c268ccb4213a3d1a18c18df1a350f163b2f.tar.bz2
pianobar-64f10c268ccb4213a3d1a18c18df1a350f163b2f.zip
ui: Declare more HTTP errors as “temporary”
This should improve the situation with unreliable HTTP proxies. See #725.
Diffstat (limited to 'src')
-rw-r--r--src/ui.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/ui.c b/src/ui.c
index 1ab54ae..204179c 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -171,6 +171,27 @@ int progressCb (void * const data, double dltotal, double dlnow,
}
}
+/* Error codes from libcurl, which may be temporary and should be retried.
+ */
+static bool temporaryCurlError (const CURLcode code) {
+ switch (code) {
+ case CURLE_COULDNT_RESOLVE_PROXY:
+ case CURLE_COULDNT_RESOLVE_HOST:
+ case CURLE_COULDNT_CONNECT:
+ case CURLE_WEIRD_SERVER_REPLY:
+ case CURLE_READ_ERROR:
+ case CURLE_OPERATION_TIMEDOUT:
+ case CURLE_SSL_CONNECT_ERROR:
+ case CURLE_GOT_NOTHING:
+ case CURLE_SEND_ERROR:
+ case CURLE_RECV_ERROR:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
#define setAndCheck(k,v) \
httpret = curl_easy_setopt (http, k, v); \
assert (httpret == CURLE_OK);
@@ -248,7 +269,7 @@ static CURLcode BarPianoHttpRequest (CURL * const http,
do {
httpret = curl_easy_perform (http);
++retry;
- if (httpret == CURLE_OPERATION_TIMEDOUT) {
+ if (temporaryCurlError (httpret)) {
free (buffer.data);
buffer.data = NULL;
buffer.pos = 0;