mirror of
https://github.com/curl/curl.git
synced 2026-08-25 10:53:37 +03:00
curl: support -w '%{num_retries}
Suggested-by: Jay Guerette Ref: https://github.com/curl/curl/discussions/13901 Closes #13910
This commit is contained in:
parent
b55c56a745
commit
d69ee3ef83
8 changed files with 24 additions and 9 deletions
|
|
@ -510,7 +510,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||
|
||||
/* if retry-max-time is non-zero, make sure we haven't exceeded the
|
||||
time */
|
||||
if(per->retry_numretries &&
|
||||
if(per->retry_remaining &&
|
||||
(!config->retry_maxtime ||
|
||||
(tvdiff(tvnow(), per->retrystart) <
|
||||
config->retry_maxtime*1000L)) ) {
|
||||
|
|
@ -632,9 +632,9 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||
warnf(config->global, "Problem %s. "
|
||||
"Will retry in %ld seconds. "
|
||||
"%ld retries left.",
|
||||
m[retry], sleeptime/1000L, per->retry_numretries);
|
||||
m[retry], sleeptime/1000L, per->retry_remaining);
|
||||
|
||||
per->retry_numretries--;
|
||||
per->retry_remaining--;
|
||||
if(!config->retry_delay) {
|
||||
per->retry_sleep *= 2;
|
||||
if(per->retry_sleep > RETRY_SLEEP_MAX)
|
||||
|
|
@ -672,10 +672,11 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||
outs->bytes = 0; /* clear for next round */
|
||||
}
|
||||
*retryp = TRUE;
|
||||
per->num_retries++;
|
||||
*delay = sleeptime;
|
||||
return CURLE_OK;
|
||||
}
|
||||
} /* if retry_numretries */
|
||||
} /* if retry_remaining */
|
||||
noretry:
|
||||
|
||||
if((global->progressmode == CURL_PROGRESS_BAR) &&
|
||||
|
|
@ -2265,7 +2266,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||
/* initialize retry vars for loop below */
|
||||
per->retry_sleep_default = (config->retry_delay) ?
|
||||
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */
|
||||
per->retry_numretries = config->req_retry;
|
||||
per->retry_remaining = config->req_retry;
|
||||
per->retry_sleep = per->retry_sleep_default; /* ms */
|
||||
per->retrystart = tvnow();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ struct per_transfer {
|
|||
struct OperationConfig *config; /* for this transfer */
|
||||
struct curl_certinfo *certinfo;
|
||||
CURL *curl;
|
||||
long retry_numretries;
|
||||
long retry_remaining;
|
||||
long retry_sleep_default;
|
||||
long retry_sleep;
|
||||
long num_retries; /* counts the performed retries */
|
||||
struct timeval start; /* start of this transfer */
|
||||
struct timeval retrystart;
|
||||
char *this_url;
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ static const struct writeoutvar variables[] = {
|
|||
{"num_connects", VAR_NUM_CONNECTS, CURLINFO_NUM_CONNECTS, writeLong},
|
||||
{"num_headers", VAR_NUM_HEADERS, CURLINFO_NONE, writeLong},
|
||||
{"num_redirects", VAR_REDIRECT_COUNT, CURLINFO_REDIRECT_COUNT, writeLong},
|
||||
{"num_retries", VAR_NUM_RETRY, CURLINFO_NONE, writeLong},
|
||||
{"onerror", VAR_ONERROR, CURLINFO_NONE, NULL},
|
||||
{"proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT,
|
||||
CURLINFO_PROXY_SSL_VERIFYRESULT, writeLong},
|
||||
|
|
@ -443,6 +444,10 @@ static int writeLong(FILE *stream, const struct writeoutvar *wovar,
|
|||
}
|
||||
else {
|
||||
switch(wovar->id) {
|
||||
case VAR_NUM_RETRY:
|
||||
longinfo = per->num_retries;
|
||||
valid = true;
|
||||
break;
|
||||
case VAR_NUM_CERTS:
|
||||
certinfo(per);
|
||||
longinfo = per->certinfo ? per->certinfo->num_of_certs : 0;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ typedef enum {
|
|||
VAR_NUM_CERTS,
|
||||
VAR_NUM_CONNECTS,
|
||||
VAR_NUM_HEADERS,
|
||||
VAR_NUM_RETRY,
|
||||
VAR_ONERROR,
|
||||
VAR_PRETRANSFER_TIME,
|
||||
VAR_PRIMARY_IP,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue