diff options
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); |