diff options
author | Yang Tse <yangsita@gmail.com> | 2010-02-25 06:59:04 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-02-25 06:59:04 +0000 |
commit | 6a8aa246ffa65c33a7d99916e2d24d98b16ae85d (patch) | |
tree | 1990ec10b7186f7f251c06260fea61eeae26b58f /tests | |
parent | e25c5283d8056b9ede00957deb8d19cfd5bfeaa9 (diff) | |
download | curl-6a8aa246ffa65c33a7d99916e2d24d98b16ae85d.tar.gz |
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 'tests')
-rw-r--r-- | tests/server/util.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/server/util.c b/tests/server/util.c index e8d20ebbd..42abeed87 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -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); |