|
3 | 3 | #include <curl/curl.h> |
4 | 4 | #include <getopt.h> |
5 | 5 | #include <stddef.h> |
6 | | -#include <unistd.h> |
7 | 6 |
|
8 | 7 | #include "caprotocol.h" |
9 | 8 | #include "caremote.h" |
@@ -172,45 +171,6 @@ static int make_curl_easy_handle(CURL **ret, |
172 | 171 | return 0; |
173 | 172 | } |
174 | 173 |
|
175 | | -static CURLcode robust_curl_easy_perform(CURL *curl) { |
176 | | - uint64_t sleep_base_usec = 100 * 1000; |
177 | | - unsigned trial = 1; |
178 | | - unsigned limit = 10; |
179 | | - CURLcode c; |
180 | | - |
181 | | - assert(curl); |
182 | | - |
183 | | - while (trial < limit) { |
184 | | - |
185 | | - c = curl_easy_perform(curl); |
186 | | - |
187 | | - switch (c) { |
188 | | - |
189 | | - case CURLE_COULDNT_CONNECT: { |
190 | | - uint64_t sleep_usec; |
191 | | - |
192 | | - /* Although this is not considered as a transient error by curl, |
193 | | - * this error can happen momentarily while casync is retrieving |
194 | | - * all the chunks from a remote. In this case we want to give |
195 | | - * a break to the server and retry later. |
196 | | - */ |
197 | | - |
198 | | - sleep_usec = sleep_base_usec * trial; |
199 | | - log_info("Could not connect, retrying in %" PRIu64 " ms", sleep_usec / 1000); |
200 | | - usleep(sleep_usec); |
201 | | - trial++; |
202 | | - break; |
203 | | - } |
204 | | - |
205 | | - default: |
206 | | - return c; |
207 | | - break; |
208 | | - } |
209 | | - } |
210 | | - |
211 | | - return c; |
212 | | -} |
213 | | - |
214 | 174 | static int process_remote(CaRemote *rr, ProcessUntil until) { |
215 | 175 | int r; |
216 | 176 |
|
@@ -453,7 +413,7 @@ static int acquire_file(CaRemote *rr, CURL *handle) { |
453 | 413 |
|
454 | 414 | log_debug("Acquiring %s...", url); |
455 | 415 |
|
456 | | - c = robust_curl_easy_perform(handle); |
| 416 | + c = curl_easy_perform(handle); |
457 | 417 | if (c != CURLE_OK) |
458 | 418 | return log_error_curle(c, "Failed to acquire %s", url); |
459 | 419 |
|
@@ -528,7 +488,7 @@ static int acquire_chunks(CaRemote *rr, const char *store_url) { |
528 | 488 |
|
529 | 489 | log_debug("Acquiring %s...", url_buffer); |
530 | 490 |
|
531 | | - c = robust_curl_easy_perform(curl); |
| 491 | + c = curl_easy_perform(curl); |
532 | 492 | if (c != CURLE_OK) |
533 | 493 | return log_error_curle(c, "Failed to acquire %s", url_buffer); |
534 | 494 |
|
|
0 commit comments