diff options
author | Daniel Stenberg <daniel@haxx.se> | 2001-10-12 12:32:20 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2001-10-12 12:32:20 +0000 |
commit | 532bca41e59e10a86c356058831cf046a3ba78c9 (patch) | |
tree | dfaa7d33d510af6ea4db11724583ca0a26159cf7 | |
parent | b438c46764b680a314000b7ca69bb1d898379d0f (diff) |
Curl_tvdiff() now returns a millisecond diff, no double like before
-rw-r--r-- | lib/connect.c | 8 | ||||
-rw-r--r-- | lib/speedcheck.c | 3 | ||||
-rw-r--r-- | lib/timeval.c | 5 | ||||
-rw-r--r-- | lib/timeval.h | 5 | ||||
-rw-r--r-- | lib/url.c | 4 |
5 files changed, 15 insertions, 10 deletions
diff --git a/lib/connect.c b/lib/connect.c index 1ec33ecab..df34d7edc 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -353,7 +353,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ if(data->set.timeout || data->set.connecttimeout) { double has_passed; - /* Evaluate how much that that has passed */ + /* Evaluate in milliseconds how much time that has passed */ has_passed = Curl_tvdiff(Curl_tvnow(), data->progress.start); #ifndef min @@ -368,7 +368,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ timeout_ms = data->set.connecttimeout*1000; /* subtract the passed time */ - timeout_ms -= (long)(has_passed * 1000); + timeout_ms -= (long)has_passed; if(timeout_ms < 0) /* a precaution, no need to continue if time already is up */ @@ -436,7 +436,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ /* get a new timeout for next attempt */ after = Curl_tvnow(); - timeout_ms -= (long)(Curl_tvdiff(after, before)*1000); + timeout_ms -= Curl_tvdiff(after, before); if(timeout_ms < 0) { failf(data, "connect() timed out!"); return CURLE_OPERATION_TIMEOUTED; @@ -521,7 +521,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ if(0 != rc) { /* get a new timeout for next attempt */ after = Curl_tvnow(); - timeout_ms -= (long)(Curl_tvdiff(after, before)*1000); + timeout_ms -= Curl_tvdiff(after, before); if(timeout_ms < 0) { failf(data, "Connect timeout on IP number %d", aliasindex+1); break; diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 3860d10d6..0b393c0c7 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -51,7 +51,8 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, for "low speed time" seconds we consider that enough reason to abort the download. */ - if( Curl_tvdiff(now, data->state.keeps_speed) > data->set.low_speed_time) { + if( (Curl_tvdiff(now, data->state.keeps_speed)/1000) > + data->set.low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " diff --git a/lib/timeval.c b/lib/timeval.c index d30ff74b2..f9284349d 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -69,9 +69,10 @@ struct timeval Curl_tvnow (void) * Make sure that the first argument is the more recent time, as otherwise * we'll get a weird negative time-diff back... */ -double Curl_tvdiff (struct timeval t1, struct timeval t2) +long Curl_tvdiff (struct timeval t1, struct timeval t2) { - return (double)(t1.tv_sec - t2.tv_sec) + ((t1.tv_usec-t2.tv_usec)/1000000.0); + return (t1.tv_sec*1000 + t1.tv_usec/1000)- + (t2.tv_sec*1000 + t2.tv_usec/1000); } long Curl_tvlong (struct timeval t1) diff --git a/lib/timeval.h b/lib/timeval.h index a37852598..84ab79601 100644 --- a/lib/timeval.h +++ b/lib/timeval.h @@ -43,7 +43,10 @@ struct timeval { #endif struct timeval Curl_tvnow (); -double Curl_tvdiff (struct timeval t1, struct timeval t2); + +/* the diff is from now on returned in number of milliseconds! */ +long Curl_tvdiff (struct timeval t1, struct timeval t2); + long Curl_tvlong (struct timeval t1); #endif @@ -1055,14 +1055,14 @@ ConnectionKillOne(struct SessionHandle *data) * Set higher score for the age passed since the connection * was used. */ - score = Curl_tvlong(now) - Curl_tvlong(conn->now); + score = Curl_tvdiff(now, conn->now); break; case CURLCLOSEPOLICY_OLDEST: /* * Set higher score for the age passed since the connection * was created. */ - score = Curl_tvlong(now) - Curl_tvlong(conn->created); + score = Curl_tvdiff(now, conn->created); break; } |