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:
Viktor Szakats 2025-03-09 13:14:31 +01:00
parent b1faac8039
commit 436d4a360a
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
20 changed files with 129 additions and 292 deletions

View file

@ -55,8 +55,8 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
}
if(config->timeout_ms) {
struct timeval now = tvnow();
long msdelta = tvdiff(now, per->start);
struct curltime now = curlx_now();
long msdelta = (long)curlx_timediff(now, per->start);
if(msdelta > config->timeout_ms)
/* timeout */
@ -132,17 +132,16 @@ int tool_readbusy_cb(void *clientp,
if(config->readbusy) {
/* lame code to keep the rate down because the input might not deliver
anything, get paused again and come back here immediately */
static long rate = 500;
static struct timeval prev;
static timediff_t rate = 500;
static struct curltime prev;
static curl_off_t ulprev;
if(ulprev == ulnow) {
/* it did not upload anything since last call */
struct timeval now = tvnow();
struct curltime now = curlx_now();
if(prev.tv_sec)
/* get a rolling average rate */
/* rate = rate - rate/4 + tvdiff(now, prev)/4; */
rate -= rate/4 - tvdiff(now, prev)/4;
rate -= rate/4 - curlx_timediff(now, prev)/4;
prev = now;
}
else {