From f09d9a4c371ea7754eb9525c2d08ec882baab836 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 18 Oct 2011 18:32:47 +0100 Subject: [PATCH] log: use localtime_r instead of localtime localtime_r does not have the side-effect of behaving like it called tzset(), in particular it will save one stat(/etc/localtime) syscall. This is not a big deal, but it makes the strace output cleaner and thus more useful :). --- src/log.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/log.c b/src/log.c index 5e1c35eb..c258b19b 100644 --- a/src/log.c +++ b/src/log.c @@ -87,12 +87,13 @@ void add_loglevel(const char *level) { * */ void vlog(char *fmt, va_list args) { - char timebuf[64]; + static char timebuf[64]; + static struct tm result; /* Get current time */ time_t t = time(NULL); /* Convert time to local time (determined by the locale) */ - struct tm *tmp = localtime(&t); + struct tm *tmp = localtime_r(&t, &result); /* Generate time prefix */ strftime(timebuf, sizeof(timebuf), "%x %X - ", tmp); #ifdef DEBUG_TIMING -- 2.39.5