diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-06-17 09:16:57 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-06-17 16:41:56 +0200 |
commit | 57166cf898fb46830448778f47c825c876a263f1 (patch) | |
tree | ed2043de6b522e0206394c70c24993b113017dd7 /lib/easy.c | |
parent | 8bc25c590e530de87595d1bb3577f699eb1309b9 (diff) | |
download | curl-57166cf898fb46830448778f47c825c876a263f1.tar.gz |
time: reduce calls to Curl_now()
Curl_now() returns the current time with microsecond accuracy - but
should not be used superfluously.
Instead use Curl_mnow(), which is a cached "reasonably updated" current
time. To force a time refresh, use Curl_now_update(). Each API entry
point should force a time refresh, as well as after any potential waits
or delays.
As an extra debug-helper: debug builds will get a check in Curl_mnow()
that compares the "cached" time with the Curl_now() time and warns on
stderr if the delta is 5000 microseconds or more. It also keeps the
source name + line number of the most recent update to aid.
Fixes #5574
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/easy.c b/lib/easy.c index 292cca7f6..4e30cc719 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -507,12 +507,10 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) } /* get the time stamp to use to figure out how long poll takes */ - before = Curl_now(); - + before = Curl_mnow(multi); /* wait for activity or timeout */ pollrc = Curl_poll(fds, numfds, ev->ms); - - after = Curl_now(); + after = Curl_now_update(multi); ev->msbump = FALSE; /* reset here */ |