From: Martin Mares Date: Fri, 20 Jan 2006 19:47:21 +0000 (+0000) Subject: It seems that signal safety of time-related functions is even more subtle X-Git-Tag: holmes-import~688 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=6ff61377466b0dcc92aacddb62236773bd6c7d1d;p=libucw.git 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. --- 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++ = ' ';