mirror of
https://github.com/curl/curl.git
synced 2026-08-25 19:03:33 +03:00
curltime: use libcurl time functions in src and tests/server
The curl tool and tests/server used 2 parallel implementations of libcurl's `Curl_now()` and `Curl_timediff()` functions. Make them use the libcurl one. Closes #16653
This commit is contained in:
parent
b1faac8039
commit
436d4a360a
20 changed files with 129 additions and 292 deletions
|
|
@ -408,7 +408,7 @@ static CURLcode pre_transfer(struct GlobalConfig *global,
|
|||
my_setopt_offt(per->curl, CURLOPT_INFILESIZE_LARGE, uploadfilesize);
|
||||
}
|
||||
per->uploadfilesize = uploadfilesize;
|
||||
per->start = tvnow();
|
||||
per->start = curlx_now();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -522,7 +522,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||
time */
|
||||
if(per->retry_remaining &&
|
||||
(!config->retry_maxtime ||
|
||||
(tvdiff(tvnow(), per->retrystart) <
|
||||
(curlx_timediff(curlx_now(), per->retrystart) <
|
||||
config->retry_maxtime*1000L)) ) {
|
||||
enum {
|
||||
RETRY_NO,
|
||||
|
|
@ -627,7 +627,8 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||
maximum time allowed for retrying, then exit the retries right
|
||||
away */
|
||||
if(config->retry_maxtime) {
|
||||
curl_off_t seconds = tvdiff(tvnow(), per->retrystart)/1000;
|
||||
curl_off_t seconds = curlx_timediff(curlx_now(),
|
||||
per->retrystart)/1000;
|
||||
|
||||
if((CURL_OFF_T_MAX - retry_after < seconds) ||
|
||||
(seconds + retry_after > config->retry_maxtime)) {
|
||||
|
|
@ -2305,7 +2306,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */
|
||||
per->retry_remaining = config->req_retry;
|
||||
per->retry_sleep = per->retry_sleep_default; /* ms */
|
||||
per->retrystart = tvnow();
|
||||
per->retrystart = curlx_now();
|
||||
|
||||
state->li++;
|
||||
/* Here's looping around each globbed URL */
|
||||
|
|
@ -2440,7 +2441,7 @@ struct parastate {
|
|||
CURLMcode mcode;
|
||||
CURLcode result;
|
||||
int still_running;
|
||||
struct timeval start;
|
||||
struct curltime start;
|
||||
bool more_transfers;
|
||||
bool added_transfers;
|
||||
/* wrapitup is set TRUE after a critical error occurs to end all transfers */
|
||||
|
|
@ -2771,7 +2772,7 @@ static CURLcode parallel_transfers(struct GlobalConfig *global,
|
|||
s->mcode = CURLM_OK;
|
||||
s->result = CURLE_OK;
|
||||
s->still_running = 1;
|
||||
s->start = tvnow();
|
||||
s->start = curlx_now();
|
||||
s->wrapitup = FALSE;
|
||||
s->wrapitup_processed = FALSE;
|
||||
s->tick = time(NULL);
|
||||
|
|
@ -2858,9 +2859,9 @@ static CURLcode serial_transfers(struct GlobalConfig *global,
|
|||
bool retry;
|
||||
long delay_ms;
|
||||
bool bailout = FALSE;
|
||||
struct timeval start;
|
||||
struct curltime start;
|
||||
|
||||
start = tvnow();
|
||||
start = curlx_now();
|
||||
if(!per->skip) {
|
||||
result = pre_transfer(global, per);
|
||||
if(result)
|
||||
|
|
@ -2923,12 +2924,13 @@ static CURLcode serial_transfers(struct GlobalConfig *global,
|
|||
if(per && global->ms_per_transfer) {
|
||||
/* how long time did the most recent transfer take in number of
|
||||
milliseconds */
|
||||
long milli = tvdiff(tvnow(), start);
|
||||
timediff_t milli = curlx_timediff(curlx_now(), start);
|
||||
if(milli < global->ms_per_transfer) {
|
||||
notef(global, "Transfer took %ld ms, waits %ldms as set by --rate",
|
||||
milli, global->ms_per_transfer - milli);
|
||||
notef(global, "Transfer took %" CURL_FORMAT_CURL_OFF_T " ms, "
|
||||
"waits %ldms as set by --rate",
|
||||
milli, (long)(global->ms_per_transfer - milli));
|
||||
/* The transfer took less time than wanted. Wait a little. */
|
||||
tool_go_sleep(global->ms_per_transfer - milli);
|
||||
tool_go_sleep((long)(global->ms_per_transfer - milli));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue