1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Curl_tvdiff() now returns a millisecond diff, no double like before

This commit is contained in:
Daniel Stenberg 2001-10-12 12:32:20 +00:00
parent b438c46764
commit 532bca41e5
5 changed files with 15 additions and 10 deletions

View File

@ -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;

View File

@ -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. "

View File

@ -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)

View File

@ -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

View File

@ -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;
}