aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-25 06:59:04 +0000
committerYang Tse <yangsita@gmail.com>2010-02-25 06:59:04 +0000
commit6a8aa246ffa65c33a7d99916e2d24d98b16ae85d (patch)
tree1990ec10b7186f7f251c06260fea61eeae26b58f /src
parente25c5283d8056b9ede00957deb8d19cfd5bfeaa9 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index b60aeb1e6..8acf032fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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 &&