diff options
author | Daniel Stenberg <daniel@haxx.se> | 2017-10-23 12:05:49 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2017-10-25 09:54:37 +0200 |
commit | b9d25f9a6b3ca791385b80a6a3c3fa5ae113e1e0 (patch) | |
tree | ad56d8b7a703e96e9de0ef07bacab079b7169904 /lib/easy.c | |
parent | 016c6a6abb525ffb9431a00a4eda6b70683f838e (diff) |
timediff: return timediff_t from the time diff functions
... to cater for systems with unsigned time_t variables.
- Renamed the functions to curlx_timediff and Curl_timediff_us.
- Added overflow protection for both of them in either direction for
both 32 bit and 64 bit time_ts
- Reprefixed the curlx_time functions to use Curl_*
Reported-by: Peter Piekarski
Fixes #2004
Closes #2005
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/easy.c b/lib/easy.c index 5328f9c2d..212d6f3da 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -586,12 +586,12 @@ 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 = curlx_tvnow(); + before = Curl_tvnow(); /* wait for activity or timeout */ pollrc = Curl_poll(fds, numfds, (int)ev->ms); - after = curlx_tvnow(); + after = Curl_tvnow(); ev->msbump = FALSE; /* reset here */ @@ -619,7 +619,7 @@ 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. */ - time_t timediff = curlx_tvdiff(after, before); + timediff_t timediff = Curl_timediff(after, before); if(timediff > 0) { if(timediff > ev->ms) ev->ms = 0; @@ -680,17 +680,17 @@ static CURLcode easy_transfer(struct Curl_multi *multi) int still_running = 0; int rc; - before = curlx_tvnow(); + before = Curl_tvnow(); mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc); if(!mcode) { if(!rc) { - struct curltime after = curlx_tvnow(); + struct curltime after = Curl_tvnow(); /* If it returns without any filedescriptor instantly, we need to avoid busy-looping during periods where it has nothing particular to wait for */ - if(curlx_tvdiff(after, before) <= 10) { + if(Curl_timediff(after, before) <= 10) { without_fds++; if(without_fds > 2) { int sleep_ms = without_fds < 10 ? (1 << (without_fds - 1)) : 1000; |