cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: bug in time calculations

From: T. Bharath <TBharath_at_responsenetworks.com>
Date: Wed, 01 Nov 2000 17:27:57 -0500

I am attaching a patch which tries to solve that .It gives the sum of the
dnslookup and connect times in the case of a redirection.Do look into that

Regards
Bharath
"T. Bharath" wrote:

> Consider a case where the server redirects us using a location field.In
> this case the calls to
> pgrsTime(data, DNS_LOOKUP);
> pgrsTime(data, TIMER_CONNECT); /* we're connected */
>
> will get called for every redirection and ultimately when we make a
> call to
> curl_easy_getinfo(curlparam->curlhandle, CURLINFO_NAMELOOKUP_TIME,
> &dnstime)
> curl_easy_getinfo(curlparam->curlhandle, CURLINFO_CONNECT_TIME,
> &connecttime)
> the value we get will not be the right one.
>
> Regards
> Bharath
> _______________________________________________
> Curl-library mailing list
> Curl-library_at_lists.sourceforge.net
> http://lists.sourceforge.net/mailman/listinfo/curl-library

--- d:\curlsource\curl-7.4.2-pre2\lib\progress.c Mon Sep 25 17:49:38 2000
+++ c:\anaconda\curl\source\lib\progress.c Wed Nov 01 11:55:22 2000
@@ -117,18 +117,25 @@
   }
 }
 
-void pgrsTime(struct UrlData *data, timerid timer)
+void pgrsTime(struct UrlData *data, timerid timer,...)
 {
+ struct timeval temp,now;
+ va_list arg;
+ va_start(arg, timer);
   switch(timer) {
   default:
   case TIMER_NONE:
     /* mistake filter */
     break;
   case TIMER_NAMELOOKUP:
- data->progress.t_nslookup = tvnow();
+ temp=va_arg(arg, struct timeval);
+ now = tvnow();
+ data->progress.t_nslookup = data->progress.t_nslookup + tvdiff(now,temp);
     break;
   case TIMER_CONNECT:
- data->progress.t_connect = tvnow();
+ temp=va_arg(arg, struct timeval);
+ now = tvnow();
+ data->progress.t_connect = data->progress.t_connect + tvdiff(now,temp);
     break;
   case TIMER_PRETRANSFER:
     data->progress.t_pretransfer = tvnow();
--- d:\curlsource\curl-7.4.2-pre2\lib\progress.h Tue Jun 20 11:34:50 2000
+++ c:\anaconda\curl\source\lib\progress.h Wed Nov 01 11:31:24 2000
@@ -59,7 +59,7 @@
 void pgrsSetDownloadCounter(struct UrlData *data, double size);
 void pgrsSetUploadCounter(struct UrlData *data, double size);
 int pgrsUpdate(struct UrlData *data);
-void pgrsTime(struct UrlData *data, timerid timer);
+void pgrsTime(struct UrlData *data, timerid timer,...);
 
 
 /* Don't show progress for sizes smaller than: */
--- d:\curlsource\curl-7.4.2-pre2\lib\urldata.h Mon Oct 30 06:53:40 2000
+++ c:\anaconda\curl\source\lib\urldata.h Wed Nov 01 11:56:08 2000
@@ -245,8 +245,8 @@
   struct timeval start;
   /* various data stored for possible later report */
- struct timeval t_nslookup;
- struct timeval t_connect;
+ double t_nslookup;
+ double t_connect;
   struct timeval t_pretransfer;
   int httpcode;
 
--- d:\curlsource\curl-7.4.2-pre2\lib\url.c Mon Oct 30 06:53:40 2000
+++ c:\anaconda\curl\source\lib\url.c Wed Nov 01 12:34:10 2000

@@ -687,15 +744,13 @@
 CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
 {
- char *tmp;
- char *buf;
+ char *tmp=NULL;
+ char *buf=NULL;
   CURLcode result;
   char resumerange[12]="";
   struct UrlData *data = curl;
- struct connectdata *conn;
-#ifdef HAVE_SIGACTION
- struct sigaction sigact;
-#endif
+ struct connectdata *conn=NULL;
+ struct timeval now;
 
   if(!data || (data->handle != STRUCT_OPEN))
     return CURLE_BAD_FUNCTION_ARGUMENT; /* TBD: make error codes */
@@ -1143,7 +1196,8 @@
       strcpy(data->passwd, CURL_DEFAULT_PASSWORD);
     }
   }
-
+
+ now=tvnow();
   if(!data->bits.httpproxy) {
     /* If not connecting via a proxy, extract the port from the URL, if it is
      * there, thus overriding any defaults that might have been set above. */
@@ -1218,9 +1271,10 @@
     }
 
     free(proxydup); /* free the duplicate pointer and not the modified */
+ proxydup=NULL;
   }
- pgrsTime(data, TIMER_NAMELOOKUP);
-
+ pgrsTime(data, TIMER_NAMELOOKUP,now);
+ now = tvnow();
   data->firstsocket = socket(AF_INET, SOCK_STREAM, 0);
 
   memset((char *) &conn->serv_addr, '\0', sizeof(conn->serv_addr));
@@ -1454,7 +1503,7 @@
       return result; /* pass back errors */
   }
 
- pgrsTime(data, TIMER_CONNECT); /* we're connected */
+ pgrsTime(data, TIMER_CONNECT,now); /* we're connected */
 
   conn->now = tvnow(); /* time this *after* the connect is done */
   conn->bytecount = 0;

_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/curl-library
Received on 2000-11-02