From 6ff61377466b0dcc92aacddb62236773bd6c7d1d Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 20 Jan 2006 19:47:21 +0000 Subject: [PATCH] It seems that signal safety of time-related functions is even more subtle than I thought -- strftime() and localtime_r() can deadlock each other, probably due to access to time zone information. Replaced strftime() by a mere sprintf. --- lib/log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/log.c b/lib/log.c index e513cbe6..713fa768 100644 --- a/lib/log.c +++ b/lib/log.c @@ -45,7 +45,9 @@ vlog_msg(unsigned int cat, const char *msg, va_list args) { p = buf = alloca(buflen); *p++ = cat; - p += strftime(p, buflen, " %Y-%m-%d %H:%M:%S", &tm); + /* We cannot use strftime() here, because it's not re-entrant */ + p += sprintf(p, " %4d-%02d-%02d %02d:%02d:%02d", tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); if (log_precise_timings) p += sprintf(p, ".%06d", (int)tv.tv_usec); *p++ = ' '; -- 2.39.2