extern char *log_title; /* NULL - print no title, default is log_progname */
extern char *log_filename; /* Expanded name of the current log file */
-extern int log_switch_nest; /* log_switch() nesting counter, increment to disable automatic switches */
+extern volatile int log_switch_nest; /* log_switch() nesting counter, increment to disable automatic switches */
extern int log_pid; /* 0 if shouldn't be logged */
extern void (*log_die_hook)(void);
struct tm;
static char *log_name_patt;
static int log_params;
static int log_filename_size;
-int log_switch_nest;
+volatile int log_switch_nest;
static int
do_log_switch(struct tm *tm)
vlog_msg(unsigned int cat, const char *msg, va_list args)
{
time_t tim = time(NULL);
- struct tm *tm = localtime(&tim);
+ struct tm tm;
byte *buf, *p;
int buflen = 256;
int l, l0, r;
va_list args2;
+ if (!localtime_r(&tim, &tm))
+ bzero(&tm, sizeof(tm));
+
if (log_switch_hook)
- log_switch_hook(tm);
+ log_switch_hook(&tm);
while (1)
{
p = buf = alloca(buflen);
*p++ = cat;
- p += strftime(p, buflen, " %Y-%m-%d %H:%M:%S ", tm);
+ p += strftime(p, buflen, " %Y-%m-%d %H:%M:%S ", &tm);
if (log_title)
{
if (log_pid)