]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Curl_tvdiff() now returns a millisecond diff, no double like before
authorDaniel Stenberg <daniel@haxx.se>
Fri, 12 Oct 2001 12:32:20 +0000 (12:32 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 12 Oct 2001 12:32:20 +0000 (12:32 +0000)
lib/connect.c
lib/speedcheck.c
lib/timeval.c
lib/timeval.h
lib/url.c

index 1ec33ecab3e9b14539efe8d21a51e12ba6098678..df34d7edc5e1318c93974d38434ff79ea0168e1f 100644 (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;
index 3860d10d6870c499178ecbc84944ffbfd9e254ff..0b393c0c75a2fae87c2948d4da4cadd93d4ab38d 100644 (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. "
index d30ff74b2d6ec7804db2b424c6f68a6744596bd5..f9284349dadce98a5dcb2afec3ab4e6f75b113ef 100644 (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)
index a378525987995eacb85e8032828c5d856099b087..84ab7960162b8bcce7fb97a6cb46b5506145924f 100644 (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
index 2f85212e60afc720402c230c9a41e171d107d8b7..9b24a221bbbdd7c32d4c58d837b36ea72008c366 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -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;
     }