lib: rename curlx_timediff to curlx_timeleft_ms

Rename `Curl_timeleft()` to `Curl_timeleft_ms()` to make the units in
the returned `timediff_t` clear. (We used to always have ms there, but
with QUIC started to sometimes calc ns as well).

Rename some assigned vars without `_ms` suffix for clarity as well.

Closes #19486
This commit is contained in:
Stefan Eissing 2025-11-12 12:15:42 +01:00 committed by Daniel Stenberg
parent ca27404d27
commit 78a610cb83
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
53 changed files with 187 additions and 188 deletions

View file

@ -317,7 +317,7 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
/* This is only set to non-zero if the timer was started. */
&& (ares->happy_eyeballs_dns_time.tv_sec
|| ares->happy_eyeballs_dns_time.tv_usec)
&& (curlx_timediff(curlx_now(), ares->happy_eyeballs_dns_time)
&& (curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time)
>= HAPPY_EYEBALLS_DNS_TIMEOUT)) {
/* Remember that the EXPIRE_HAPPY_EYEBALLS_DNS timer is no longer
running. */
@ -394,47 +394,47 @@ CURLcode Curl_async_await(struct Curl_easy *data,
{
struct async_ares_ctx *ares = &data->state.async.ares;
CURLcode result = CURLE_OK;
timediff_t timeout;
timediff_t timeout_ms;
struct curltime now = curlx_now();
DEBUGASSERT(entry);
*entry = NULL; /* clear on entry */
timeout = Curl_timeleft(data, &now, TRUE);
if(timeout < 0) {
timeout_ms = Curl_timeleft_ms(data, &now, TRUE);
if(timeout_ms < 0) {
/* already expired! */
connclose(data->conn, "Timed out before name resolve started");
return CURLE_OPERATION_TIMEDOUT;
}
if(!timeout)
timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */
if(!timeout_ms)
timeout_ms = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve */
/* Wait for the name resolve query to complete. */
while(!result) {
struct timeval *tvp, tv, store;
int itimeout;
timediff_t timeout_ms;
struct timeval *real_timeout, time_buf, max_timeout;
int itimeout_ms;
timediff_t call_timeout_ms;
#if TIMEDIFF_T_MAX > INT_MAX
itimeout = (timeout > INT_MAX) ? INT_MAX : (int)timeout;
itimeout_ms = (timeout_ms > INT_MAX) ? INT_MAX : (int)timeout_ms;
#else
itimeout = (int)timeout;
itimeout_ms = (int)timeout_ms;
#endif
store.tv_sec = itimeout/1000;
store.tv_usec = (itimeout%1000)*1000;
max_timeout.tv_sec = itimeout_ms/1000;
max_timeout.tv_usec = (itimeout_ms%1000)*1000;
tvp = ares_timeout(ares->channel, &store, &tv);
real_timeout = ares_timeout(ares->channel, &max_timeout, &time_buf);
/* use the timeout period ares returned to us above if less than one
second is left, otherwise just use 1000ms to make sure the progress
callback gets called frequent enough */
if(!tvp->tv_sec)
timeout_ms = (timediff_t)(tvp->tv_usec/1000);
if(!real_timeout->tv_sec)
call_timeout_ms = (timediff_t)(real_timeout->tv_usec/1000);
else
timeout_ms = 1000;
call_timeout_ms = 1000;
if(Curl_ares_perform(ares->channel, timeout_ms) < 0)
if(Curl_ares_perform(ares->channel, call_timeout_ms) < 0)
return CURLE_UNRECOVERABLE_POLL;
result = Curl_async_is_resolved(data, entry);
@ -445,16 +445,16 @@ CURLcode Curl_async_await(struct Curl_easy *data,
result = CURLE_ABORTED_BY_CALLBACK;
else {
struct curltime now2 = curlx_now();
timediff_t timediff = curlx_timediff(now2, now); /* spent time */
if(timediff <= 0)
timeout -= 1; /* always deduct at least 1 */
else if(timediff > timeout)
timeout = -1;
timediff_t elapsed_ms = curlx_timediff_ms(now2, now); /* spent time */
if(elapsed_ms <= 0)
timeout_ms -= 1; /* always deduct at least 1 */
else if(elapsed_ms > timeout_ms)
timeout_ms = -1;
else
timeout -= timediff;
timeout_ms -= elapsed_ms;
now = now2; /* for next loop */
}
if(timeout < 0)
if(timeout_ms < 0)
result = CURLE_OPERATION_TIMEDOUT;
}

View file

@ -660,8 +660,8 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
else {
/* poll for name lookup done with exponential backoff up to 250ms */
/* should be fine even if this converts to 32-bit */
timediff_t elapsed = curlx_timediff(curlx_now(),
data->progress.t_startsingle);
timediff_t elapsed = curlx_timediff_ms(curlx_now(),
data->progress.t_startsingle);
if(elapsed < 0)
elapsed = 0;
@ -711,7 +711,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps)
result = Curl_pollset_add_in(data, ps, thrdd->addr->sock_pair[0]);
#else
timediff_t milli;
timediff_t ms = curlx_timediff(curlx_now(), thrdd->addr->start);
timediff_t ms = curlx_timediff_ms(curlx_now(), thrdd->addr->start);
if(ms < 3)
milli = 0;
else if(ms <= 50)

View file

@ -535,10 +535,8 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf,
return CURLE_RECV_ERROR; /* Need a cfilter close and new bootstrap */
do {
timediff_t check;
check = Curl_timeleft(data, NULL, TRUE);
if(check <= 0) {
if(Curl_timeleft_ms(data, NULL, TRUE) < 0) {
failf(data, "Proxy CONNECT aborted due to timeout");
result = CURLE_OPERATION_TIMEDOUT;
goto out;

View file

@ -1073,7 +1073,6 @@ static CURLcode cf_h2_proxy_connect(struct Curl_cfilter *cf,
struct cf_h2_proxy_ctx *ctx = cf->ctx;
CURLcode result = CURLE_OK;
struct cf_call_data save;
timediff_t check;
struct tunnel_stream *ts = &ctx->tunnel;
if(cf->connected) {
@ -1098,8 +1097,7 @@ static CURLcode cf_h2_proxy_connect(struct Curl_cfilter *cf,
}
DEBUGASSERT(ts->authority);
check = Curl_timeleft(data, NULL, TRUE);
if(check <= 0) {
if(Curl_timeleft_ms(data, NULL, TRUE) < 0) {
failf(data, "Proxy CONNECT aborted due to timeout");
result = CURLE_OPERATION_TIMEDOUT;
goto out;

View file

@ -215,12 +215,13 @@ static CURLcode baller_connected(struct Curl_cfilter *cf,
reply_ms = cf_hc_baller_reply_ms(winner, data);
if(reply_ms >= 0)
CURL_TRC_CF(data, cf, "connect+handshake %s: %dms, 1st data: %dms",
winner->name, (int)curlx_timediff(curlx_now(),
winner->started), reply_ms);
winner->name,
(int)curlx_timediff_ms(curlx_now(),
winner->started), reply_ms);
else
CURL_TRC_CF(data, cf, "deferred handshake %s: %dms",
winner->name, (int)curlx_timediff(curlx_now(),
winner->started));
winner->name, (int)curlx_timediff_ms(curlx_now(),
winner->started));
/* install the winning filter below this one. */
cf->next = winner->cf;
@ -269,7 +270,7 @@ static bool time_to_start_next(struct Curl_cfilter *cf,
ctx->ballers[idx].name);
return TRUE;
}
elapsed_ms = curlx_timediff(now, ctx->started);
elapsed_ms = curlx_timediff_ms(now, ctx->started);
if(elapsed_ms >= ctx->hard_eyeballs_timeout_ms) {
CURL_TRC_CF(data, cf, "hard timeout of %" FMT_TIMEDIFF_T "ms reached, "
"starting %s",

View file

@ -413,8 +413,8 @@ evaluate:
more_possible = cf_ai_iter_has_more(&bs->ipv6_iter);
#endif
do_more = more_possible &&
(curlx_timediff(now, bs->last_attempt_started) >=
bs->attempt_delay_ms);
(curlx_timediff_ms(now, bs->last_attempt_started) >=
bs->attempt_delay_ms);
if(do_more)
CURL_TRC_CF(data, cf, "happy eyeballs timeout expired, "
"start next attempt");
@ -460,7 +460,7 @@ evaluate:
else if(inconclusive) {
/* tried all addresses, no success but some where inconclusive.
* Let's restart the inconclusive ones. */
timediff_t since_ms = curlx_timediff(now, bs->last_attempt_started);
timediff_t since_ms = curlx_timediff_ms(now, bs->last_attempt_started);
timediff_t delay_ms = bs->attempt_delay_ms - since_ms;
if(delay_ms <= 0) {
CURL_TRC_CF(data, cf, "all attempts inconclusive, restarting one");
@ -505,10 +505,10 @@ out:
bool more_possible;
/* when do we need to be called again? */
next_expire_ms = Curl_timeleft(data, &now, TRUE);
next_expire_ms = Curl_timeleft_ms(data, &now, TRUE);
if(next_expire_ms <= 0) {
failf(data, "Connection timeout after %" FMT_OFF_T " ms",
curlx_timediff(now, data->progress.t_startsingle));
curlx_timediff_ms(now, data->progress.t_startsingle));
return CURLE_OPERATION_TIMEDOUT;
}
@ -519,7 +519,7 @@ out:
#endif
if(more_possible) {
timediff_t expire_ms, elapsed_ms;
elapsed_ms = curlx_timediff(now, bs->last_attempt_started);
elapsed_ms = curlx_timediff_ms(now, bs->last_attempt_started);
expire_ms = CURLMAX(bs->attempt_delay_ms - elapsed_ms, 0);
next_expire_ms = CURLMIN(next_expire_ms, expire_ms);
if(next_expire_ms <= 0) {
@ -682,7 +682,7 @@ static CURLcode is_connected(struct Curl_cfilter *cf,
proxy_name ? "via " : "",
proxy_name ? proxy_name : "",
proxy_name ? " " : "",
curlx_timediff(curlx_now(), data->progress.t_startsingle),
curlx_timediff_ms(curlx_now(), data->progress.t_startsingle),
curl_easy_strerror(result));
}
@ -707,7 +707,7 @@ static CURLcode start_connect(struct Curl_cfilter *cf,
if(!dns)
return CURLE_FAILED_INIT;
if(Curl_timeleft(data, NULL, TRUE) < 0) {
if(Curl_timeleft_ms(data, NULL, TRUE) < 0) {
/* a precaution, no need to continue if time already is up */
failf(data, "Connection time-out");
return CURLE_OPERATION_TIMEDOUT;

View file

@ -1428,7 +1428,7 @@ static void win_update_sndbuf_size(struct cf_socket_ctx *ctx)
DWORD ideallen;
struct curltime n = curlx_now();
if(curlx_timediff(n, ctx->last_sndbuf_query_at) > 1000) {
if(curlx_timediff_ms(n, ctx->last_sndbuf_query_at) > 1000) {
if(!WSAIoctl(ctx->sock, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0,
&ideal, sizeof(ideal), &ideallen, 0, 0) &&
ideal != ctx->sndbuf_size &&
@ -1701,7 +1701,7 @@ static CURLcode cf_socket_query(struct Curl_cfilter *cf,
return CURLE_OK;
case CF_QUERY_CONNECT_REPLY_MS:
if(ctx->got_first_byte) {
timediff_t ms = curlx_timediff(ctx->first_byte_at, ctx->started_at);
timediff_t ms = curlx_timediff_ms(ctx->first_byte_at, ctx->started_at);
*pres1 = (ms < INT_MAX) ? (int)ms : INT_MAX;
}
else
@ -2020,7 +2020,7 @@ static timediff_t cf_tcp_accept_timeleft(struct Curl_cfilter *cf,
{
struct cf_socket_ctx *ctx = cf->ctx;
timediff_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
timediff_t other;
timediff_t other_ms;
struct curltime now;
#ifndef CURL_DISABLE_FTP
@ -2030,14 +2030,14 @@ static timediff_t cf_tcp_accept_timeleft(struct Curl_cfilter *cf,
now = curlx_now();
/* check if the generic timeout possibly is set shorter */
other = Curl_timeleft(data, &now, FALSE);
if(other && (other < timeout_ms))
/* note that this also works fine for when other happens to be negative
other_ms = Curl_timeleft_ms(data, &now, FALSE);
if(other_ms && (other_ms < timeout_ms))
/* note that this also works fine for when other_ms happens to be negative
due to it already having elapsed */
timeout_ms = other;
timeout_ms = other_ms;
else {
/* subtract elapsed time */
timeout_ms -= curlx_timediff(now, ctx->started_at);
timeout_ms -= curlx_timediff_ms(now, ctx->started_at);
if(!timeout_ms)
/* avoid returning 0 as that means no timeout! */
timeout_ms = -1;

View file

@ -526,7 +526,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
goto out;
else {
/* check allowed time left */
const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
const timediff_t timeout_ms = Curl_timeleft_ms(data, NULL, TRUE);
curl_socket_t sockfd = Curl_conn_cf_get_socket(cf, data);
int rc;

View file

@ -299,7 +299,7 @@ cpool_bundle_get_oldest_idle(struct cpool_bundle *bundle)
if(!CONN_INUSE(conn)) {
/* Set higher score for the age passed since the connection was used */
score = curlx_timediff(now, conn->lastused);
score = curlx_timediff_ms(now, conn->lastused);
if(score > highscore) {
highscore = score;
@ -336,7 +336,7 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool)
if(CONN_INUSE(conn) || conn->bits.close || conn->connect_only)
continue;
/* Set higher score for the age passed since the connection was used */
score = curlx_timediff(now, conn->lastused);
score = curlx_timediff_ms(now, conn->lastused);
if(score > highscore) {
highscore = score;
oldest_idle = conn;
@ -745,7 +745,7 @@ void Curl_cpool_prune_dead(struct Curl_easy *data)
rctx.now = curlx_now();
CPOOL_LOCK(cpool, data);
elapsed = curlx_timediff(rctx.now, cpool->last_cleanup);
elapsed = curlx_timediff_ms(rctx.now, cpool->last_cleanup);
if(elapsed >= 1000L) {
while(cpool_foreach(data, cpool, &rctx, cpool_reap_dead_cb))

View file

@ -101,7 +101,7 @@ enum alpnid Curl_alpn2alpnid(const char *name, size_t len)
#endif
/*
* Curl_timeleft() returns the amount of milliseconds left allowed for the
* Curl_timeleft_ms() returns the amount of milliseconds left allowed for the
* transfer/connection. If the value is 0, there is no timeout (ie there is
* infinite time left). If the value is negative, the timeout time has already
* elapsed.
@ -110,9 +110,9 @@ enum alpnid Curl_alpn2alpnid(const char *name, size_t len)
* @param duringconnect TRUE iff connect timeout is also taken into account.
* @unittest: 1303
*/
timediff_t Curl_timeleft(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect)
timediff_t Curl_timeleft_ms(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect)
{
timediff_t timeleft_ms = 0;
timediff_t ctimeleft_ms = 0;
@ -133,7 +133,7 @@ timediff_t Curl_timeleft(struct Curl_easy *data,
if(data->set.timeout) {
timeleft_ms = data->set.timeout -
curlx_timediff(*nowp, data->progress.t_startop);
curlx_timediff_ms(*nowp, data->progress.t_startop);
if(!timeleft_ms)
timeleft_ms = -1; /* 0 is "no limit", fake 1 ms expiry */
if(!duringconnect)
@ -144,7 +144,7 @@ timediff_t Curl_timeleft(struct Curl_easy *data,
timediff_t ctimeout_ms = (data->set.connecttimeout > 0) ?
data->set.connecttimeout : DEFAULT_CONNECT_TIMEOUT;
ctimeleft_ms = ctimeout_ms -
curlx_timediff(*nowp, data->progress.t_startsingle);
curlx_timediff_ms(*nowp, data->progress.t_startsingle);
if(!ctimeleft_ms)
ctimeleft_ms = -1; /* 0 is "no limit", fake 1 ms expiry */
if(!timeleft_ms)
@ -191,7 +191,7 @@ timediff_t Curl_shutdown_timeleft(struct connectdata *conn, int sockindex,
nowp = &now;
}
left_ms = conn->shutdown.timeout_ms -
curlx_timediff(*nowp, conn->shutdown.start[sockindex]);
curlx_timediff_ms(*nowp, conn->shutdown.start[sockindex]);
return left_ms ? left_ms : -1;
}

View file

@ -36,9 +36,9 @@ enum alpnid Curl_alpn2alpnid(const char *name, size_t len);
/* generic function that returns how much time there is left to run, according
to the timeouts set */
timediff_t Curl_timeleft(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect);
timediff_t Curl_timeleft_ms(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect);
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */

View file

@ -291,7 +291,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
sigpipe_apply(data, &pipe_st);
while(Curl_llist_head(&cshutdn->list)) {
timediff_t timespent;
timediff_t spent_ms;
int remain_ms;
cshutdn_perform(cshutdn, data);
@ -302,14 +302,14 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
}
/* wait for activity, timeout or "nothing" */
timespent = curlx_timediff(curlx_now(), started);
if(timespent >= (timediff_t)timeout_ms) {
spent_ms = curlx_timediff_ms(curlx_now(), started);
if(spent_ms >= (timediff_t)timeout_ms) {
CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
(timeout_ms > 0) ? "timeout" : "best effort done");
break;
}
remain_ms = timeout_ms - (int)timespent;
remain_ms = timeout_ms - (int)spent_ms;
if(cshutdn_wait(cshutdn, data, remain_ms)) {
CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, aborted");
break;

View file

@ -220,7 +220,7 @@ struct curltime curlx_now(void)
*
* @unittest: 1323
*/
timediff_t curlx_timediff(struct curltime newer, struct curltime older)
timediff_t curlx_timediff_ms(struct curltime newer, struct curltime older)
{
timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
if(diff >= (TIMEDIFF_T_MAX/1000))
@ -234,7 +234,8 @@ timediff_t curlx_timediff(struct curltime newer, struct curltime older)
* Returns: time difference in number of milliseconds, rounded up.
* For too large diffs it returns max value.
*/
timediff_t curlx_timediff_ceil(struct curltime newer, struct curltime older)
timediff_t curlx_timediff_ceil_ms(struct curltime newer,
struct curltime older)
{
timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
if(diff >= (TIMEDIFF_T_MAX/1000))

View file

@ -46,7 +46,7 @@ struct curltime curlx_now(void);
*
* Returns: the time difference in number of milliseconds.
*/
timediff_t curlx_timediff(struct curltime newer, struct curltime older);
timediff_t curlx_timediff_ms(struct curltime newer, struct curltime older);
/*
* Make sure that the first argument (newer) is the more recent time and older
@ -54,7 +54,8 @@ timediff_t curlx_timediff(struct curltime newer, struct curltime older);
*
* Returns: the time difference in number of milliseconds, rounded up.
*/
timediff_t curlx_timediff_ceil(struct curltime newer, struct curltime older);
timediff_t curlx_timediff_ceil_ms(struct curltime newer,
struct curltime older);
/*
* Make sure that the first argument (newer) is the more recent time and older

View file

@ -311,7 +311,7 @@ static CURLcode doh_probe_run(struct Curl_easy *data,
goto error;
}
timeout_ms = Curl_timeleft(data, NULL, TRUE);
timeout_ms = Curl_timeleft_ms(data, NULL, TRUE);
if(timeout_ms <= 0) {
result = CURLE_OPERATION_TIMEDOUT;
goto error;

View file

@ -654,16 +654,16 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
/* If nothing updated the timeout, we decrease it by the spent time.
* If it was updated, it has the new timeout time stored already.
*/
timediff_t timediff = curlx_timediff(curlx_now(), before);
if(timediff > 0) {
timediff_t spent_ms = curlx_timediff_ms(curlx_now(), before);
if(spent_ms > 0) {
#if DEBUG_EV_POLL
curl_mfprintf(stderr, "poll timeout %ldms not updated, decrease by "
"time spent %ldms\n", ev->ms, (long)timediff);
#endif
if(timediff > ev->ms)
if(spent_ms > ev->ms)
ev->ms = 0;
else
ev->ms -= (long)timediff;
ev->ms -= (long)spent_ms;
}
}
}

View file

@ -202,7 +202,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
else
break;
timeout_ms = Curl_timeleft(data, NULL, FALSE);
timeout_ms = Curl_timeleft_ms(data, NULL, FALSE);
if(timeout_ms < 0) {
result = CURLE_OPERATION_TIMEDOUT;
break;

View file

@ -200,7 +200,7 @@ dnscache_entry_is_stale(void *datap, void *hc)
if(dns->timestamp.tv_sec || dns->timestamp.tv_usec) {
/* get age in milliseconds */
timediff_t age = curlx_timediff(prune->now, dns->timestamp);
timediff_t age = curlx_timediff_ms(prune->now, dns->timestamp);
if(!dns->addr)
age *= 2; /* negative entries age twice as fast */
if(age >= prune->max_age_ms)
@ -1177,8 +1177,8 @@ clean_up:
the time we spent until now! */
if(prev_alarm) {
/* there was an alarm() set before us, now put it back */
timediff_t elapsed_secs = curlx_timediff(curlx_now(),
data->conn->created) / 1000;
timediff_t elapsed_secs = curlx_timediff_ms(curlx_now(),
data->conn->created) / 1000;
/* the alarm period is counted in even number of seconds */
unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs);

View file

@ -4945,7 +4945,7 @@ static CURLcode cr_exp100_read(struct Curl_easy *data,
*eos = FALSE;
return CURLE_READ_ERROR;
case EXP100_AWAITING_CONTINUE:
ms = curlx_timediff(curlx_now(), ctx->start);
ms = curlx_timediff_ms(curlx_now(), ctx->start);
if(ms < data->set.expect_100_timeout) {
DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired"));
data->req.keepon &= ~KEEP_SEND;

View file

@ -847,7 +847,7 @@ static CURLcode mqtt_ping(struct Curl_easy *data)
!mq->pingsent &&
data->set.upkeep_interval_ms > 0) {
struct curltime t = curlx_now();
timediff_t diff = curlx_timediff(t, mq->lastTime);
timediff_t diff = curlx_timediff_ms(t, mq->lastTime);
if(diff > data->set.upkeep_interval_ms) {
/* 0xC0 is PINGREQ, and 0x00 is remaining length */

View file

@ -1739,7 +1739,7 @@ static bool multi_handle_timeout(struct Curl_easy *data,
CURLcode *result)
{
bool connect_timeout = data->mstate < MSTATE_DO;
timediff_t timeout_ms = Curl_timeleft(data, now, connect_timeout);
timediff_t timeout_ms = Curl_timeleft_ms(data, now, connect_timeout);
if(timeout_ms < 0) {
/* Handle timed out */
struct curltime since;
@ -1749,22 +1749,22 @@ static bool multi_handle_timeout(struct Curl_easy *data,
since = data->progress.t_startop;
if(data->mstate == MSTATE_RESOLVING)
failf(data, "Resolving timed out after %" FMT_TIMEDIFF_T
" milliseconds", curlx_timediff(*now, since));
" milliseconds", curlx_timediff_ms(*now, since));
else if(data->mstate == MSTATE_CONNECTING)
failf(data, "Connection timed out after %" FMT_TIMEDIFF_T
" milliseconds", curlx_timediff(*now, since));
" milliseconds", curlx_timediff_ms(*now, since));
else {
struct SingleRequest *k = &data->req;
if(k->size != -1) {
failf(data, "Operation timed out after %" FMT_TIMEDIFF_T
" milliseconds with %" FMT_OFF_T " out of %"
FMT_OFF_T " bytes received",
curlx_timediff(*now, since), k->bytecount, k->size);
curlx_timediff_ms(*now, since), k->bytecount, k->size);
}
else {
failf(data, "Operation timed out after %" FMT_TIMEDIFF_T
" milliseconds with %" FMT_OFF_T " bytes received",
curlx_timediff(*now, since), k->bytecount);
curlx_timediff_ms(*now, since), k->bytecount);
}
}
*result = CURLE_OPERATION_TIMEDOUT;
@ -3410,13 +3410,13 @@ static CURLMcode multi_timeout(struct Curl_multi *multi,
if(multi->timetree &&
curlx_timediff_us(multi->timetree->key, now) > 0) {
/* some time left before expiration */
timediff_t diff = curlx_timediff_ceil(multi->timetree->key, now);
timediff_t diff_ms = curlx_timediff_ceil_ms(multi->timetree->key, now);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
data = Curl_splayget(multi->timetree);
#endif
/* this should be safe even on 32-bit archs, as we do not use that
overly long timeouts */
*timeout_ms = (long)diff;
*timeout_ms = (long)diff_ms;
}
else {
#ifndef CURL_DISABLE_VERBOSE_STRINGS
@ -3574,7 +3574,7 @@ multi_addtimeout(struct Curl_easy *data,
/* find the correct spot in the list */
for(e = Curl_llist_head(timeoutlist); e; e = Curl_node_next(e)) {
struct time_node *check = Curl_node_elem(e);
timediff_t diff = curlx_timediff(check->time, node->time);
timediff_t diff = curlx_timediff_ms(check->time, node->time);
if(diff > 0)
break;
prev = e;
@ -3625,7 +3625,7 @@ void Curl_expire_ex(struct Curl_easy *data,
/* This means that the struct is added as a node in the splay tree.
Compare if the new time is earlier, and only remove-old/add-new if it
is. */
timediff_t diff = curlx_timediff(set, *curr_expire);
timediff_t diff = curlx_timediff_ms(set, *curr_expire);
int rc;
if(diff > 0) {

View file

@ -61,17 +61,17 @@ timediff_t Curl_pp_state_timeout(struct Curl_easy *data,
/* Without a requested timeout, we only wait 'response_time' seconds for the
full response to arrive before we bail out */
timeout_ms = response_time - curlx_timediff(now, pp->response);
timeout_ms = response_time - curlx_timediff_ms(now, pp->response);
if(data->set.timeout && !disconnecting) {
/* if timeout is requested, find out how much overall remains */
timediff_t timeout2_ms = Curl_timeleft(data, &now, FALSE);
timediff_t timeout2_ms = Curl_timeleft_ms(data, &now, FALSE);
/* pick the lowest number */
timeout_ms = CURLMIN(timeout_ms, timeout2_ms);
}
if(disconnecting) {
timediff_t total_left_ms = Curl_timeleft(data, NULL, FALSE);
timediff_t total_left_ms = Curl_timeleft_ms(data, NULL, FALSE);
timeout_ms = CURLMIN(timeout_ms, CURLMAX(total_left_ms, 0));
}

View file

@ -271,7 +271,7 @@ timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d,
return 0;
/* The time it took us to have `bytes` */
took_ms = curlx_timediff_ceil(now, d->limit.start);
took_ms = curlx_timediff_ceil_ms(now, d->limit.start);
/* The time it *should* have taken us to have `bytes`
* when obeying the bytes_per_sec speed_limit. */
@ -311,14 +311,14 @@ void Curl_ratelimit(struct Curl_easy *data, struct curltime now)
{
/* do not set a new stamp unless the time since last update is long enough */
if(data->set.max_recv_speed) {
if(curlx_timediff(now, data->progress.dl.limit.start) >=
if(curlx_timediff_ms(now, data->progress.dl.limit.start) >=
MIN_RATE_LIMIT_PERIOD) {
data->progress.dl.limit.start = now;
data->progress.dl.limit.start_size = data->progress.dl.cur_size;
}
}
if(data->set.max_send_speed) {
if(curlx_timediff(now, data->progress.ul.limit.start) >=
if(curlx_timediff_ms(now, data->progress.ul.limit.start) >=
MIN_RATE_LIMIT_PERIOD) {
data->progress.ul.limit.start = now;
data->progress.ul.limit.start_size = data->progress.ul.cur_size;
@ -424,7 +424,7 @@ static bool progress_calc(struct Curl_easy *data, struct curltime now)
checkindex = (p->speeder_c >= CURR_TIME) ? p->speeder_c%CURR_TIME : 0;
/* Figure out the exact time for the time span */
span_ms = curlx_timediff(now, p->speeder_time[checkindex]);
span_ms = curlx_timediff_ms(now, p->speeder_time[checkindex]);
if(span_ms == 0)
span_ms = 1; /* at least one millisecond MUST have passed */

View file

@ -54,7 +54,7 @@ int Curl_rename(const char *oldpath, const char *newpath)
curlx_unicodefree(tchar_newpath);
break;
}
diff = curlx_timediff(curlx_now(), start);
diff = curlx_timediff_ms(curlx_now(), start);
if(diff < 0 || diff > max_wait_ms) {
curlx_unicodefree(tchar_oldpath);
curlx_unicodefree(tchar_newpath);

View file

@ -228,7 +228,7 @@ int Curl_socketpair(int domain, int type, int protocol,
if(nread == -1) {
int sockerr = SOCKERRNO;
/* Do not block forever */
if(curlx_timediff(curlx_now(), start) > (60 * 1000))
if(curlx_timediff_ms(curlx_now(), start) > (60 * 1000))
goto error;
if(
#ifdef USE_WINSOCK

View file

@ -137,7 +137,7 @@ CURLcode Curl_blockread_all(struct Curl_cfilter *cf,
*pnread = 0;
for(;;) {
timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
timediff_t timeout_ms = Curl_timeleft_ms(data, NULL, TRUE);
if(timeout_ms < 0) {
/* we already got the timeout */
return CURLE_OPERATION_TIMEDOUT;

View file

@ -53,7 +53,7 @@ CURLcode Curl_speedcheck(struct Curl_easy *data,
data->state.keeps_speed = now;
else {
/* how long has it been under the limit */
timediff_t howlong = curlx_timediff(now, data->state.keeps_speed);
timediff_t howlong = curlx_timediff_ms(now, data->state.keeps_speed);
if(howlong >= data->set.low_speed_time * 1000) {
/* too long */

View file

@ -1531,7 +1531,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
if(data->set.timeout) {
now = curlx_now();
if(curlx_timediff(now, conn->created) >= data->set.timeout) {
if(curlx_timediff_ms(now, conn->created) >= data->set.timeout) {
failf(data, "Time-out");
result = CURLE_OPERATION_TIMEDOUT;
keepon = FALSE;
@ -1652,7 +1652,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
if(data->set.timeout) {
now = curlx_now();
if(curlx_timediff(now, conn->created) >= data->set.timeout) {
if(curlx_timediff_ms(now, conn->created) >= data->set.timeout) {
failf(data, "Time-out");
result = CURLE_OPERATION_TIMEDOUT;
keepon = FALSE;

View file

@ -211,7 +211,7 @@ static CURLcode tftp_set_timeouts(struct tftp_conn *state)
bool start = (state->state == TFTP_STATE_START);
/* Compute drop-dead time */
timeout_ms = Curl_timeleft(state->data, NULL, start);
timeout_ms = Curl_timeleft_ms(state->data, NULL, start);
if(timeout_ms < 0) {
/* time-out, bail out, go home */
@ -1199,8 +1199,8 @@ static timediff_t tftp_state_timeout(struct tftp_conn *state,
if(event)
*event = TFTP_EVENT_NONE;
timeout_ms = Curl_timeleft(state->data, NULL,
(state->state == TFTP_STATE_START));
timeout_ms = Curl_timeleft_ms(state->data, NULL,
(state->state == TFTP_STATE_START));
if(timeout_ms < 0) {
state->error = TFTP_ERR_TIMEOUT;
state->state = TFTP_STATE_FIN;

View file

@ -422,18 +422,18 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp)
goto out;
if(k->keepon) {
if(0 > Curl_timeleft(data, nowp, FALSE)) {
if(Curl_timeleft_ms(data, nowp, FALSE) < 0) {
if(k->size != -1) {
failf(data, "Operation timed out after %" FMT_TIMEDIFF_T
" milliseconds with %" FMT_OFF_T " out of %"
FMT_OFF_T " bytes received",
curlx_timediff(*nowp, data->progress.t_startsingle),
curlx_timediff_ms(*nowp, data->progress.t_startsingle),
k->bytecount, k->size);
}
else {
failf(data, "Operation timed out after %" FMT_TIMEDIFF_T
" milliseconds with %" FMT_OFF_T " bytes received",
curlx_timediff(*nowp, data->progress.t_startsingle),
curlx_timediff_ms(*nowp, data->progress.t_startsingle),
k->bytecount);
}
result = CURLE_OPERATION_TIMEDOUT;

View file

@ -655,7 +655,7 @@ static bool conn_maxage(struct Curl_easy *data,
timediff_t age_ms;
if(data->set.conn_max_idle_ms) {
age_ms = curlx_timediff(now, conn->lastused);
age_ms = curlx_timediff_ms(now, conn->lastused);
if(age_ms > data->set.conn_max_idle_ms) {
infof(data, "Too old connection (%" FMT_TIMEDIFF_T
" ms idle, max idle is %" FMT_TIMEDIFF_T " ms), disconnect it",
@ -665,7 +665,7 @@ static bool conn_maxage(struct Curl_easy *data,
}
if(data->set.conn_max_age_ms) {
age_ms = curlx_timediff(now, conn->created);
age_ms = curlx_timediff_ms(now, conn->created);
if(age_ms > data->set.conn_max_age_ms) {
infof(data,
"Too old connection (created %" FMT_TIMEDIFF_T
@ -750,7 +750,7 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data,
struct curltime *now)
{
CURLcode result = CURLE_OK;
if(curlx_timediff(*now, conn->keepalive) <= data->set.upkeep_interval_ms)
if(curlx_timediff_ms(*now, conn->keepalive) <= data->set.upkeep_interval_ms)
return result;
/* briefly attach for action */
@ -3217,7 +3217,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
{
struct hostname *ehost;
int eport;
timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
timediff_t timeout_ms = Curl_timeleft_ms(data, NULL, TRUE);
const char *peertype = "host";
CURLcode result;
@ -3275,7 +3275,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
else if(result == CURLE_OPERATION_TIMEDOUT) {
failf(data, "Failed to resolve %s '%s' with timeout after %"
FMT_TIMEDIFF_T " ms", peertype, ehost->dispname,
curlx_timediff(curlx_now(), data->progress.t_startsingle));
curlx_timediff_ms(curlx_now(), data->progress.t_startsingle));
return CURLE_OPERATION_TIMEDOUT;
}
else if(result) {

View file

@ -517,11 +517,11 @@ static int cf_ngtcp2_handshake_completed(ngtcp2_conn *tconn, void *user_data)
if(Curl_trc_is_verbose(data)) {
const ngtcp2_transport_params *rp;
rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn);
CURL_TRC_CF(data, cf, "handshake complete after %dms, remote transport["
"max_udp_payload=%" FMT_PRIu64
CURL_TRC_CF(data, cf, "handshake complete after %" FMT_TIMEDIFF_T
"ms, remote transport[max_udp_payload=%" FMT_PRIu64
", initial_max_data=%" FMT_PRIu64
"]",
(int)curlx_timediff(ctx->handshake_at, ctx->started_at),
curlx_timediff_ms(ctx->handshake_at, ctx->started_at),
(curl_uint64_t)rp->max_udp_payload_size,
(curl_uint64_t)rp->initial_max_data);
}
@ -2722,7 +2722,7 @@ static CURLcode cf_ngtcp2_query(struct Curl_cfilter *cf,
}
case CF_QUERY_CONNECT_REPLY_MS:
if(ctx->q.got_first_byte) {
timediff_t ms = curlx_timediff(ctx->q.first_byte_at, ctx->started_at);
timediff_t ms = curlx_timediff_ms(ctx->q.first_byte_at, ctx->started_at);
*pres1 = (ms < INT_MAX) ? (int)ms : INT_MAX;
}
else
@ -2783,7 +2783,7 @@ static bool cf_ngtcp2_conn_is_alive(struct Curl_cfilter *cf,
* it will close the connection when it expires. */
rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn);
if(rp && rp->max_idle_timeout) {
timediff_t idletime_ms = curlx_timediff(curlx_now(), ctx->q.last_io);
timediff_t idletime_ms = curlx_timediff_ms(curlx_now(), ctx->q.last_io);
if(idletime_ms > 0) {
uint64_t max_idle_ms =
(uint64_t)(rp->max_idle_timeout / NGTCP2_MILLISECONDS);

View file

@ -1805,8 +1805,8 @@ static CURLcode cf_osslq_connect(struct Curl_cfilter *cf,
/* connected */
ctx->handshake_at = now;
ctx->q.last_io = now;
CURL_TRC_CF(data, cf, "handshake complete after %dms",
(int)curlx_timediff(now, ctx->started_at));
CURL_TRC_CF(data, cf, "handshake complete after %" FMT_TIMEDIFF_T "ms",
curlx_timediff_ms(now, ctx->started_at));
result = cf_osslq_verify_peer(cf, data);
if(!result) {
CURL_TRC_CF(data, cf, "peer verified");
@ -2247,7 +2247,7 @@ static bool cf_osslq_conn_is_alive(struct Curl_cfilter *cf,
}
CURL_TRC_CF(data, cf, "negotiated idle timeout: %" FMT_PRIu64 "ms",
(curl_uint64_t)idle_ms);
idletime = curlx_timediff(curlx_now(), ctx->q.last_io);
idletime = curlx_timediff_ms(curlx_now(), ctx->q.last_io);
if(idle_ms && idletime > 0 && (uint64_t)idletime > idle_ms)
goto out;
}
@ -2337,7 +2337,7 @@ static CURLcode cf_osslq_query(struct Curl_cfilter *cf,
}
case CF_QUERY_CONNECT_REPLY_MS:
if(ctx->got_first_byte) {
timediff_t ms = curlx_timediff(ctx->first_byte_at, ctx->started_at);
timediff_t ms = curlx_timediff_ms(ctx->first_byte_at, ctx->started_at);
*pres1 = (ms < INT_MAX) ? (int)ms : INT_MAX;
}
else

View file

@ -1402,8 +1402,8 @@ static CURLcode cf_quiche_connect(struct Curl_cfilter *cf,
if(quiche_conn_is_established(ctx->qconn)) {
ctx->handshake_at = ctx->q.last_op;
CURL_TRC_CF(data, cf, "handshake complete after %dms",
(int)curlx_timediff(ctx->handshake_at, ctx->started_at));
CURL_TRC_CF(data, cf, "handshake complete after %" FMT_TIMEDIFF_T "ms",
curlx_timediff_ms(ctx->handshake_at, ctx->started_at));
result = cf_quiche_verify_peer(cf, data);
if(!result) {
CURL_TRC_CF(data, cf, "peer verified");
@ -1534,7 +1534,7 @@ static CURLcode cf_quiche_query(struct Curl_cfilter *cf,
}
case CF_QUERY_CONNECT_REPLY_MS:
if(ctx->q.got_first_byte) {
timediff_t ms = curlx_timediff(ctx->q.first_byte_at, ctx->started_at);
timediff_t ms = curlx_timediff_ms(ctx->q.first_byte_at, ctx->started_at);
*pres1 = (ms < INT_MAX) ? (int)ms : INT_MAX;
}
else

View file

@ -2481,7 +2481,7 @@ static CURLcode myssh_block_statemach(struct Curl_easy *data,
while((sshc->state != SSH_STOP) && !result) {
bool block;
timediff_t left = 1000;
timediff_t left_ms = 1000;
struct curltime now = curlx_now();
result = myssh_statemach_act(data, sshc, sshp, &block);
@ -2496,8 +2496,8 @@ static CURLcode myssh_block_statemach(struct Curl_easy *data,
if(result)
break;
left = Curl_timeleft(data, NULL, FALSE);
if(left < 0) {
left_ms = Curl_timeleft_ms(data, NULL, FALSE);
if(left_ms < 0) {
failf(data, "Operation timed out");
return CURLE_OPERATION_TIMEDOUT;
}
@ -2506,8 +2506,8 @@ static CURLcode myssh_block_statemach(struct Curl_easy *data,
if(block) {
curl_socket_t fd_read = conn->sock[FIRSTSOCKET];
/* wait for the socket to become ready */
(void)Curl_socket_check(fd_read, CURL_SOCKET_BAD,
CURL_SOCKET_BAD, left > 1000 ? 1000 : left);
(void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, CURL_SOCKET_BAD,
left_ms > 1000 ? 1000 : left_ms);
}
}

View file

@ -3124,7 +3124,7 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
while((sshc->state != SSH_STOP) && !result) {
bool block;
timediff_t left = 1000;
timediff_t left_ms = 1000;
struct curltime now = curlx_now();
result = ssh_statemachine(data, sshc, sshp, &block);
@ -3139,13 +3139,13 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
if(result)
break;
left = Curl_timeleft(data, NULL, FALSE);
if(left < 0) {
left_ms = Curl_timeleft_ms(data, NULL, FALSE);
if(left_ms < 0) {
failf(data, "Operation timed out");
return CURLE_OPERATION_TIMEDOUT;
}
}
else if(curlx_timediff(now, dis) > 1000) {
else if(curlx_timediff_ms(now, dis) > 1000) {
/* disconnect timeout */
failf(data, "Disconnect timed out");
result = CURLE_OK;
@ -3163,7 +3163,7 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
fd_write = sock;
/* wait for the socket to become ready */
(void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write,
left > 1000 ? 1000 : left);
left_ms > 1000 ? 1000 : left_ms);
}
}

View file

@ -544,7 +544,7 @@ static bool gtls_shared_creds_expired(const struct Curl_easy *data,
{
const struct ssl_general_config *cfg = &data->set.general_ssl;
struct curltime now = curlx_now();
timediff_t elapsed_ms = curlx_timediff(now, sc->time);
timediff_t elapsed_ms = curlx_timediff_ms(now, sc->time);
timediff_t timeout_ms = cfg->ca_cache_timeout * (timediff_t)1000;
if(timeout_ms < 0)

View file

@ -3573,7 +3573,7 @@ ossl_cached_x509_store_expired(const struct Curl_easy *data,
return FALSE;
else {
struct curltime now = curlx_now();
timediff_t elapsed_ms = curlx_timediff(now, mb->time);
timediff_t elapsed_ms = curlx_timediff_ms(now, mb->time);
timediff_t timeout_ms = cfg->ca_cache_timeout * (timediff_t)1000;
return elapsed_ms >= timeout_ms;

View file

@ -1767,7 +1767,7 @@ schannel_recv_renegotiate(struct Curl_cfilter *cf, struct Curl_easy *data,
curl_socket_t readfd, writefd;
timediff_t elapsed;
elapsed = curlx_timediff(curlx_now(), rs->start_time);
elapsed = curlx_timediff_ms(curlx_now(), rs->start_time);
if(elapsed >= MAX_RENEG_BLOCK_TIME) {
failf(data, "schannel: renegotiation timeout");
result = CURLE_SSL_CONNECT_ERROR;
@ -1827,14 +1827,14 @@ schannel_recv_renegotiate(struct Curl_cfilter *cf, struct Curl_easy *data,
for(;;) {
int what;
timediff_t timeout, remaining;
timediff_t timeout_ms, remaining;
if(Curl_pgrsUpdate(data)) {
result = CURLE_ABORTED_BY_CALLBACK;
break;
}
elapsed = curlx_timediff(curlx_now(), rs->start_time);
elapsed = curlx_timediff_ms(curlx_now(), rs->start_time);
if(elapsed >= MAX_RENEG_BLOCK_TIME) {
failf(data, "schannel: renegotiation timeout");
result = CURLE_SSL_CONNECT_ERROR;
@ -1843,31 +1843,31 @@ schannel_recv_renegotiate(struct Curl_cfilter *cf, struct Curl_easy *data,
remaining = MAX_RENEG_BLOCK_TIME - elapsed;
if(blocking) {
timeout = Curl_timeleft(data, NULL, FALSE);
timeout_ms = Curl_timeleft_ms(data, NULL, FALSE);
if(timeout < 0) {
if(timeout_ms < 0) {
result = CURLE_OPERATION_TIMEDOUT;
break;
}
/* the blocking is in intervals so that the progress function can be
called every second */
if(!timeout || timeout > 1000)
timeout = 1000;
if(!timeout_ms || timeout_ms > 1000)
timeout_ms = 1000;
if(timeout > remaining)
timeout = remaining;
if(timeout_ms > remaining)
timeout_ms = remaining;
}
else
timeout = 0;
timeout_ms = 0;
SCH_DEV(infof(data, "schannel: renegotiation wait until socket is"
"%s%s for up to %" FMT_TIMEDIFF_T " ms",
((readfd != CURL_SOCKET_BAD) ? " readable" : ""),
((writefd != CURL_SOCKET_BAD) ? " writeable" : ""),
timeout));
timeout_ms));
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, timeout);
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, timeout_ms);
if(what > 0 && (what & (CURL_CSELECT_IN | CURL_CSELECT_OUT))) {
SCH_DEV(infof(data, "schannel: renegotiation socket %s%s",
@ -1997,7 +1997,7 @@ schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data,
while(len > *pnwritten) {
size_t this_write = 0;
int what;
timediff_t timeout_ms = Curl_timeleft(data, NULL, FALSE);
timediff_t timeout_ms = Curl_timeleft_ms(data, NULL, FALSE);
if(timeout_ms < 0) {
/* we already got the timeout */
failf(data, "schannel: timed out sending data "
@ -2801,7 +2801,7 @@ HCERTSTORE Curl_schannel_get_cached_cert_store(struct Curl_cfilter *cf,
timeout_ms = cfg->ca_cache_timeout * (timediff_t)1000;
if(timeout_ms >= 0) {
now = curlx_now();
elapsed_ms = curlx_timediff(now, share->time);
elapsed_ms = curlx_timediff_ms(now, share->time);
if(elapsed_ms >= timeout_ms) {
return NULL;
}

View file

@ -733,7 +733,7 @@ wssl_cached_x509_store_expired(const struct Curl_easy *data,
{
const struct ssl_general_config *cfg = &data->set.general_ssl;
struct curltime now = curlx_now();
timediff_t elapsed_ms = curlx_timediff(now, mb->time);
timediff_t elapsed_ms = curlx_timediff_ms(now, mb->time);
timediff_t timeout_ms = cfg->ca_cache_timeout * (timediff_t)1000;
if(timeout_ms < 0)

View file

@ -1703,7 +1703,7 @@ static CURLcode ws_send_raw_blocking(struct Curl_easy *data,
CURL_TRC_WS(data, "ws_send_raw_blocking() partial, %zu left to send",
buflen);
left_ms = Curl_timeleft(data, NULL, FALSE);
left_ms = Curl_timeleft_ms(data, NULL, FALSE);
if(left_ms < 0) {
failf(data, "[WS] Timeout waiting for socket becoming writable");
return CURLE_SEND_ERROR;

View file

@ -171,13 +171,13 @@ int tool_progress_cb(void *clientp,
if(bar->prev == point)
/* progress did not change since last invoke */
return 0;
else if((curlx_timediff(now, bar->prevtime) < 100L) && point < total)
else if((curlx_timediff_ms(now, bar->prevtime) < 100L) && point < total)
/* limit progress-bar updating to 10 Hz except when we are at 100% */
return 0;
}
else {
/* total is unknown */
if(curlx_timediff(now, bar->prevtime) < 100L)
if(curlx_timediff_ms(now, bar->prevtime) < 100L)
/* limit progress-bar updating to 10 Hz */
return 0;
update_width(bar);

View file

@ -101,7 +101,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
if(config->timeout_ms) {
struct curltime now = curlx_now();
long msdelta = (long)curlx_timediff(now, per->start);
long msdelta = (long)curlx_timediff_ms(now, per->start);
if(msdelta > config->timeout_ms)
/* timeout */

View file

@ -476,7 +476,7 @@ static CURLcode retrycheck(struct OperationConfig *config,
maximum time allowed for retrying, then exit the retries right
away */
if(config->retry_maxtime_ms) {
timediff_t ms = curlx_timediff(curlx_now(), per->retrystart);
timediff_t ms = curlx_timediff_ms(curlx_now(), per->retrystart);
if((CURL_OFF_T_MAX - sleeptime < ms) ||
(ms + sleeptime > config->retry_maxtime_ms)) {
@ -713,7 +713,7 @@ static CURLcode post_per_transfer(struct per_transfer *per,
time */
if(per->retry_remaining &&
(!config->retry_maxtime_ms ||
(curlx_timediff(curlx_now(), per->retrystart) <
(curlx_timediff_ms(curlx_now(), per->retrystart) <
config->retry_maxtime_ms)) ) {
result = retrycheck(config, per, result, retryp, delay);
if(!result && *retryp)
@ -1984,7 +1984,7 @@ static CURLcode serial_transfers(CURLSH *share)
if(per && global->ms_per_transfer) {
/* how long time did the most recent transfer take in number of
milliseconds */
timediff_t milli = curlx_timediff(curlx_now(), start);
timediff_t milli = curlx_timediff_ms(curlx_now(), start);
if(milli < global->ms_per_transfer) {
notef("Transfer took %" CURL_FORMAT_CURL_OFF_T " ms, "
"waits %ldms as set by --rate",

View file

@ -156,7 +156,7 @@ bool progress_meter(CURLM *multi,
return FALSE;
now = curlx_now();
diff = curlx_timediff(now, stamp);
diff = curlx_timediff_ms(now, stamp);
if(!header) {
header = TRUE;
@ -169,7 +169,7 @@ bool progress_meter(CURLM *multi,
char time_total[10];
char time_spent[10];
char buffer[3][6];
curl_off_t spent = curlx_timediff(now, *start)/1000;
curl_off_t spent = curlx_timediff_ms(now, *start)/1000;
char dlpercen[4]="--";
char ulpercen[4]="--";
struct per_transfer *per;
@ -236,13 +236,13 @@ bool progress_meter(CURLM *multi,
curl_off_t uls;
if(indexwrapped) {
/* 'speedindex' is the oldest stored data */
deltams = curlx_timediff(now, speedstore[speedindex].stamp);
deltams = curlx_timediff_ms(now, speedstore[speedindex].stamp);
dl = all_dlnow - speedstore[speedindex].dl;
ul = all_ulnow - speedstore[speedindex].ul;
}
else {
/* since the beginning */
deltams = curlx_timediff(now, *start);
deltams = curlx_timediff_ms(now, *start);
dl = all_dlnow;
ul = all_ulnow;
}

View file

@ -2,7 +2,7 @@
<info>
<keywords>
unittest
Curl_timeleft
Curl_timeleft_ms
</keywords>
</info>
@ -13,7 +13,7 @@ Curl_timeleft
unittest
</features>
<name>
Curl_timeleft unit tests
Curl_timeleft_ms unit tests
</name>
</client>
</testcase>

View file

@ -461,7 +461,7 @@ void ws_close(CURL *curl);
#define TEST_HANG_TIMEOUT 60 * 1000 /* global default */
#define exe_test_timedout(T,Y,Z) do { \
timediff_t timediff = curlx_timediff(curlx_now(), tv_test_start); \
timediff_t timediff = curlx_timediff_ms(curlx_now(), tv_test_start); \
if(timediff > (T)) { \
curl_mfprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
"that it would have run forever (%ld ms > %ld ms)\n", \

View file

@ -87,7 +87,7 @@ static CURLcode test_lib1501(const char *URL)
abort_on_test_timeout_custom(HANG_TIMEOUT);
after = curlx_now();
e = curlx_timediff(after, before);
e = curlx_timediff_ms(after, before);
curl_mfprintf(stderr, "pong = %ld\n", (long)e);
if(e > MAX_BLOCKED_TIME_MS) {

View file

@ -112,7 +112,7 @@ static CURLcode test_lib1507(const char *URL)
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
if(curlx_timediff(curlx_now(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
if(curlx_timediff_ms(curlx_now(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
curl_mfprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
break;

View file

@ -49,7 +49,7 @@ static CURLcode test_lib1564(const char *URL)
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = curlx_now();
if(curlx_timediff(time_after_wait, time_before_wait) < 500) {
if(curlx_timediff_ms(time_after_wait, time_before_wait) < 500) {
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
@ -66,7 +66,7 @@ static CURLcode test_lib1564(const char *URL)
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = curlx_now();
if(curlx_timediff(time_after_wait, time_before_wait) > 500) {
if(curlx_timediff_ms(time_after_wait, time_before_wait) > 500) {
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too late\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
@ -81,7 +81,7 @@ static CURLcode test_lib1564(const char *URL)
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = curlx_now();
if(curlx_timediff(time_after_wait, time_before_wait) < 500) {
if(curlx_timediff_ms(time_after_wait, time_before_wait) < 500) {
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
@ -99,7 +99,7 @@ static CURLcode test_lib1564(const char *URL)
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = curlx_now();
if(curlx_timediff(time_after_wait, time_before_wait) > 500) {
if(curlx_timediff_ms(time_after_wait, time_before_wait) > 500) {
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too late\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
@ -114,7 +114,7 @@ static CURLcode test_lib1564(const char *URL)
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = curlx_now();
if(curlx_timediff(time_after_wait, time_before_wait) < 500) {
if(curlx_timediff_ms(time_after_wait, time_before_wait) < 500) {
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;

View file

@ -148,7 +148,7 @@ static CURLcode test_unit1303(const char *arg)
timediff_t timeout;
NOW(run[i].now_s, run[i].now_us);
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
timeout = Curl_timeleft(easy, &now, run[i].connecting);
timeout = Curl_timeleft_ms(easy, &now, run[i].connecting);
if(timeout != run[i].result)
fail(run[i].comment);
}

View file

@ -43,7 +43,7 @@ static CURLcode test_unit1323(const char *arg)
size_t i;
for(i = 0; i < CURL_ARRAYSIZE(tests); i++) {
timediff_t result = curlx_timediff(tests[i].first, tests[i].second);
timediff_t result = curlx_timediff_ms(tests[i].first, tests[i].second);
if(result != tests[i].result) {
curl_mprintf("%ld.%06u to %ld.%06u got %" FMT_TIMEDIFF_T
", but expected %" FMT_TIMEDIFF_T "\n",

View file

@ -122,7 +122,7 @@ static void cf_test_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
struct cf_test_ctx *ctx = cf->ctx;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
infof(data, "%04dms: cf[%s] destroyed",
(int)curlx_timediff(curlx_now(), current_tr->started), ctx->id);
(int)curlx_timediff_ms(curlx_now(), current_tr->started), ctx->id);
#else
(void)data;
#endif
@ -139,7 +139,7 @@ static CURLcode cf_test_connect(struct Curl_cfilter *cf,
(void)data;
*done = FALSE;
duration_ms = curlx_timediff(curlx_now(), ctx->started);
duration_ms = curlx_timediff_ms(curlx_now(), ctx->started);
if(duration_ms >= ctx->fail_delay_ms) {
infof(data, "%04dms: cf[%s] fail delay reached",
(int)duration_ms, ctx->id);
@ -218,7 +218,7 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf,
ctx->stats->creations++;
}
created_at = curlx_timediff(ctx->started, current_tr->started);
created_at = curlx_timediff_ms(ctx->started, current_tr->started);
if(ctx->stats->creations == 1)
ctx->stats->first_created = created_at;
ctx->stats->last_created = created_at;
@ -245,7 +245,7 @@ static void check_result(const struct test_case *tc,
char msg[256];
timediff_t duration_ms;
duration_ms = curlx_timediff(tr->ended, tr->started);
duration_ms = curlx_timediff_ms(tr->ended, tr->started);
curl_mfprintf(stderr, "%d: test case took %dms\n", tc->id, (int)duration_ms);
if(tr->result != tc->exp_result
@ -267,7 +267,7 @@ static void check_result(const struct test_case *tc,
fail(msg);
}
duration_ms = curlx_timediff(tr->ended, tr->started);
duration_ms = curlx_timediff_ms(tr->ended, tr->started);
if(duration_ms < tc->min_duration_ms) {
curl_msprintf(msg, "%d: expected min duration of %dms, but took %dms",
tc->id, (int)tc->min_duration_ms, (int)duration_ms);