-const char errlog_rcs[] = "$Id: errlog.c,v 1.127 2016/12/24 16:00:49 fabiankeil Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.128 2017/05/29 10:06:09 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
void log_error(int loglevel, const char *fmt, ...)
{
va_list ap;
- char *outbuf = NULL;
- static char *outbuf_save = NULL;
+ char outbuf[LOG_BUFFER_SIZE+1];
char tempbuf[LOG_BUFFER_SIZE];
size_t length = 0;
const char * src = fmt;
long thread_id;
char timestamp[30];
- /*
- * XXX: Make this a config option,
- * why else do we allocate instead of using
- * an array?
- */
const size_t log_buffer_size = LOG_BUFFER_SIZE;
#if defined(_WIN32) && !defined(_WIN_CONSOLE)
thread_id = get_thread_id();
get_log_timestamp(timestamp, sizeof(timestamp));
- /* protect the whole function because of the static buffer (outbuf) */
- lock_logfile();
-
- if (NULL == outbuf_save)
- {
- outbuf_save = zalloc_or_die(log_buffer_size + 1); /* +1 for paranoia */
- }
- outbuf = outbuf_save;
-
/*
* Memsetting the whole buffer to zero (in theory)
* makes things easier later on.
*/
- memset(outbuf, 0, log_buffer_size);
+ memset(outbuf, 0, sizeof(outbuf));
/* Add prefix for everything but Common Log Format messages */
if (loglevel != LOG_LEVEL_CLF)
assert(NULL != logfp);
#endif
+ lock_logfile();
+
if (loglevel == LOG_LEVEL_FATAL)
{
- fatal_error(outbuf_save);
+ fatal_error(outbuf);
/* Never get here */
}
if (logfp != NULL)
{
- fputs(outbuf_save, logfp);
+ fputs(outbuf, logfp);
}
#if defined(_WIN32) && !defined(_WIN_CONSOLE)