mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
more retry stuff
This commit is contained in:
parent
1887629c5c
commit
fd884a3cd2
7
CHANGES
7
CHANGES
@ -6,7 +6,14 @@
|
||||
|
||||
Changelog
|
||||
|
||||
Daniel (4 November 2004)
|
||||
- Andres Garcia made it build on mingw againa, my --retry code broke the build.
|
||||
|
||||
Daniel (2 November 2004)
|
||||
- Added --retry-max-time that allows a maximum time that may not have been
|
||||
reached for a retry to be made. If not set there is no maximum time, only
|
||||
the amount of retries set with --retry.
|
||||
|
||||
- Paul Nolan provided a patch to make libcurl build nicely on Windows CE.
|
||||
|
||||
Daniel (1 November 2004)
|
||||
|
30
docs/curl.1
30
docs/curl.1
@ -726,26 +726,32 @@ If this option is used twice, the second time disables this again.
|
||||
.IP "--retry <num>"
|
||||
If a transient error is returned when curl tries to perform a transfer, it
|
||||
will retry this number of times before giving up. Setting the number to 0
|
||||
makes curl do no retries (which is the default).
|
||||
|
||||
Transient error means either: timeout, an FTP 5xx response code or a HTTP 5xx
|
||||
response code.
|
||||
makes curl do no retries (which is the default). Transient error means either:
|
||||
a timeout, an FTP 5xx response code or an HTTP 5xx response code.
|
||||
|
||||
When curl is about to retry a transfer, it will first wait one second and then
|
||||
for all forthcoming retries it will double the waiting time until it reaches
|
||||
10 minutes which then will be the delay between the rest of the retries.
|
||||
|
||||
By using \fI--retry-delay\fP you disable this exponential backoff algorithm.
|
||||
(Option added in 7.12.3)
|
||||
10 minutes which then will be the delay between the rest of the retries. By
|
||||
using \fI--retry-delay\fP you disable this exponential backoff algorithm. See
|
||||
also \fI--retry-max-time\fP to limit the total time allowed for
|
||||
retries. (Option added in 7.12.3)
|
||||
|
||||
If this option is used multiple times, the last occurance decide the amount.
|
||||
.IP "--retry-delay <seconds>"
|
||||
Make curl sleep this amount of time between each retry when a transfer has
|
||||
failed with a transient error (it changes the default backoff time algorithm
|
||||
between retries). This option is only interestinf if \fI--retry\fP is also
|
||||
used. (Option added in 7.12.3)
|
||||
between retries). This option is only interesting if \fI--retry\fP is also
|
||||
used. Setting this delay to zero will make curl use the default backoff time.
|
||||
(Option added in 7.12.3)
|
||||
|
||||
Setting the delay to zero will make curl use the default backoff time.
|
||||
If this option is used multiple times, the last occurance decide the amount.
|
||||
.IP "--retry-max-time <seconds>"
|
||||
The retry timer is reset before the first transfer attempt. Retries will be
|
||||
done as usual (see \fI--retry\fP) as long as the timer hasn't reached this
|
||||
given limit. Notice that if the timer hasn't reached the limit, the request
|
||||
will be made and while performing, it may take longer than this given time
|
||||
period. To limit a single request\'s maximum time, use \fI-m/--max-time\fP.
|
||||
Set this option to zero to not timeout retries. (Option added in 7.12.3)
|
||||
|
||||
If this option is used multiple times, the last occurance decide the amount.
|
||||
.IP "-s/--silent"
|
||||
@ -845,7 +851,7 @@ starting with '>' means data sent by curl, '<' means data received by curl
|
||||
that is hidden in normal cases and lines starting with '*' means additional
|
||||
info provided by curl.
|
||||
|
||||
Note that if you want to see HTTP headers in the output, \fI-i/--include\fP
|
||||
Note that if you only want HTTP headers in the output, \fI-i/--include\fP
|
||||
might be option you're looking for.
|
||||
|
||||
If you think this option still doesn't give you enough details, consider using
|
||||
|
17
src/main.c
17
src/main.c
@ -386,6 +386,7 @@ static void help(void)
|
||||
" -R/--remote-time Set the remote file's time on the local output",
|
||||
" --retry <num> Retry request <num> times if transient problems occur",
|
||||
" --retry-delay <seconds> When retrying, wait this many seconds between each",
|
||||
" --retry-max-time <seconds> Retry only within this period",
|
||||
" -s/--silent Silent mode. Don't output anything",
|
||||
" -S/--show-error Show error. With -s, make curl show errors when they occur",
|
||||
" --socks <host[:port]> Use SOCKS5 proxy on given host + port",
|
||||
@ -529,6 +530,7 @@ struct Configurable {
|
||||
bool tcp_nodelay;
|
||||
long req_retry; /* number of retries */
|
||||
long retry_delay; /* delay between retries (in seconds) */
|
||||
long retry_maxtime; /* maximum time to keep retrying */
|
||||
};
|
||||
|
||||
/* global variable to hold info about libcurl */
|
||||
@ -1212,6 +1214,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
{"$f", "proxy-basic", FALSE},
|
||||
{"$g", "retry", TRUE},
|
||||
{"$h", "retry-delay", TRUE},
|
||||
{"$i", "retry-max-time", TRUE},
|
||||
{"0", "http1.0", FALSE},
|
||||
{"1", "tlsv1", FALSE},
|
||||
{"2", "sslv2", FALSE},
|
||||
@ -1555,6 +1558,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
if(str2num(&config->retry_delay, nextarg))
|
||||
return PARAM_BAD_NUMERIC;
|
||||
break;
|
||||
case 'i': /* --retry-max-time */
|
||||
if(str2num(&config->retry_maxtime, nextarg))
|
||||
return PARAM_BAD_NUMERIC;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '#': /* added 19990617 larsa */
|
||||
@ -2809,6 +2816,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
long retry_numretries;
|
||||
long retry_sleep = retry_sleep_default;
|
||||
long response;
|
||||
struct timeval retrystart;
|
||||
|
||||
char *env;
|
||||
#ifdef CURLDEBUG
|
||||
@ -3513,10 +3521,17 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
|
||||
retry_numretries = config->req_retry;
|
||||
|
||||
retrystart = curlx_tvnow();
|
||||
|
||||
do {
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(retry_numretries) {
|
||||
/* if retry-max-time is non-zero, make sure we haven't exceeded the
|
||||
time */
|
||||
if(retry_numretries &&
|
||||
(!config->retry_maxtime ||
|
||||
(curlx_tvdiff(curlx_tvnow(), retrystart)<
|
||||
config->retry_maxtime*1000)) ) {
|
||||
enum {
|
||||
RETRY_NO,
|
||||
RETRY_TIMEOUT,
|
||||
|
Loading…
Reference in New Issue
Block a user