]> granicus.if.org Git - curl/commitdiff
Fixed bug report #2958074 indicating
authorYang Tse <yangsita@gmail.com>
Thu, 25 Feb 2010 06:59:04 +0000 (06:59 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 25 Feb 2010 06:59:04 +0000 (06:59 +0000)
(http://curl.haxx.se/bug/view.cgi?id=2958074) that curl on Windows with
option --trace-time did not use local time when timestamping trace lines.
This could also happen on other systems depending on time souurce.

CHANGES
RELEASE-NOTES
src/main.c
tests/server/util.c

diff --git a/CHANGES b/CHANGES
index 79f0c6ed4b3bda4a3ea7dd117abdfea91730354d..d6013b782c69070f62f16e7a19a415a7c852c8f9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,12 @@
 
                                   Changelog
 
+Yang Tse (25 Feb 2010)
+- I fixed bug report #2958074 indicating
+  (http://curl.haxx.se/bug/view.cgi?id=2958074) that curl on Windows with
+  option --trace-time did not use local time when timestamping trace lines.
+  This could also happen on other systems depending on time souurce.
+
 Patrick Monnerat (22 Feb 2010)
 - Proper handling of STARTTLS on SMTP, taking CURLUSESSL_TRY into account.
 - SMTP falls back to RFC821 HELO when EHLO fails (and SSL is not required).
index 1d32f380abdccfd3c844b3ee197ae2d1c4f51fa5..c33e6a0cec8ba24502034890072a067969e1f174 100644 (file)
@@ -19,6 +19,7 @@ This release includes the following bugfixes:
  o missing quote in libcurl.m4
  o SMTP: now waits for 250 after the DATA transfer
  o SMTP: use angle brackets in RCPT TO
+ o curl --trace-time not using local time
 
 This release includes the following known bugs:
 
index b60aeb1e68d8919b5e4401731a77842e73b1b6ce..8acf032feb565ce3dd61f69916567bc213981f98 100644 (file)
@@ -580,10 +580,7 @@ struct Configurable {
   /* for bandwidth limiting features: */
   curl_off_t sendpersecond; /* send to peer */
   curl_off_t recvpersecond; /* receive from peer */
-  struct timeval lastsendtime;
-  size_t lastsendsize;
-  struct timeval lastrecvtime;
-  size_t lastrecvsize;
+
   bool ftp_ssl;
   bool ftp_ssl_reqd;
   bool ftp_ssl_control;
@@ -3651,15 +3648,22 @@ int my_trace(CURL *handle, curl_infotype type,
   struct tm *now;
   char timebuf[20];
   time_t secs;
+  static time_t epoch_offset;
+  static int    known_offset;
 
   (void)handle; /* prevent compiler warning */
 
-  tv = cutil_tvnow();
-  secs = tv.tv_sec;
-  now = localtime(&secs);  /* not multithread safe but we don't care */
-  if(config->tracetime)
+  if(config->tracetime) {
+    tv = cutil_tvnow();
+    if(!known_offset) {
+      epoch_offset = time(NULL) - tv.tv_sec;
+      known_offset = 1;
+    }
+    secs = epoch_offset + tv.tv_sec;
+    now = localtime(&secs);  /* not thread safe but we don't care */
     snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
              now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
+  }
   else
     timebuf[0]=0;
 
@@ -4263,8 +4267,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
   config->showerror=TRUE;
   config->use_httpget=FALSE;
   config->create_dirs=FALSE;
-  config->lastrecvtime = cutil_tvnow();
-  config->lastsendtime = cutil_tvnow();
   config->maxredirs = DEFAULT_MAXREDIRS;
 
   if(argc>1 &&
index e8d20ebbdd5a7b605f860970f8d1c11b1557e2b2..42abeed8743a8eae501d3caea80eec95e3b94b8a 100644 (file)
@@ -72,6 +72,8 @@ void logmsg(const char *msg, ...)
   time_t sec;
   struct tm *now;
   char timebuf[20];
+  static time_t epoch_offset;
+  static int    known_offset;
 
   if (!serverlogfile) {
     fprintf(stderr, "Error: serverlogfile not set\n");
@@ -79,8 +81,12 @@ void logmsg(const char *msg, ...)
   }
 
   tv = curlx_tvnow();
-  sec = tv.tv_sec;
-  now = localtime(&sec); /* not multithread safe but we don't care */
+  if(!known_offset) {
+    epoch_offset = time(NULL) - tv.tv_sec;
+    known_offset = 1;
+  }
+  sec = epoch_offset + tv.tv_sec;
+  now = localtime(&sec); /* not thread safe but we don't care */
 
   snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld",
     (int)now->tm_hour, (int)now->tm_min, (int)now->tm_sec, (long)tv.tv_usec);