From b9d25f9a6b3ca791385b80a6a3c3fa5ae113e1e0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 23 Oct 2017 12:05:49 +0200 Subject: 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 --- lib/url.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/url.c') diff --git a/lib/url.c b/lib/url.c index 76c09c72a..594160898 100644 --- a/lib/url.c +++ b/lib/url.c @@ -3459,8 +3459,8 @@ Curl_oldest_idle_connection(struct Curl_easy *data) struct curl_hash_iterator iter; struct curl_llist_element *curr; struct curl_hash_element *he; - time_t highscore =- 1; - time_t score; + timediff_t highscore =- 1; + timediff_t score; struct curltime now; struct connectdata *conn_candidate = NULL; struct connectbundle *bundle; @@ -3481,7 +3481,7 @@ Curl_oldest_idle_connection(struct Curl_easy *data) if(!conn->inuse) { /* Set higher score for the age passed since the connection was used */ - score = Curl_tvdiff(now, conn->now); + score = Curl_timediff(now, conn->now); if(score > highscore) { highscore = score; @@ -3522,8 +3522,8 @@ find_oldest_idle_connection_in_bundle(struct Curl_easy *data, struct connectbundle *bundle) { struct curl_llist_element *curr; - time_t highscore = -1; - time_t score; + timediff_t highscore = -1; + timediff_t score; struct curltime now; struct connectdata *conn_candidate = NULL; struct connectdata *conn; @@ -3538,7 +3538,7 @@ find_oldest_idle_connection_in_bundle(struct Curl_easy *data, if(!conn->inuse) { /* Set higher score for the age passed since the connection was used */ - score = Curl_tvdiff(now, conn->now); + score = Curl_timediff(now, conn->now); if(score > highscore) { highscore = score; @@ -3613,7 +3613,7 @@ static int call_disconnect_if_dead(struct connectdata *conn, static void prune_dead_connections(struct Curl_easy *data) { struct curltime now = Curl_tvnow(); - time_t elapsed = Curl_tvdiff(now, data->state.conn_cache->last_cleanup); + time_t elapsed = Curl_timediff(now, data->state.conn_cache->last_cleanup); if(elapsed >= 1000L) { Curl_conncache_foreach(data->state.conn_cache, data, -- cgit v1.2.3