add a mutex in logging functions so that multiple threads can log at the same time

This commit is contained in:
Isaac Connor 2018-11-23 12:45:41 -05:00
parent 61759a1f2d
commit 4d4666f5e0
2 changed files with 6 additions and 0 deletions

View File

@ -444,6 +444,7 @@ void Logger::closeSyslog() {
void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) {
if ( level > mEffectiveLevel )
return;
log_mutex.lock();
char timeString[64];
char logString[8192];
va_list argPtr;
@ -579,6 +580,7 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
abort();
exit(-1);
}
log_mutex.unlock();
}

View File

@ -30,6 +30,8 @@
#endif // HAVE_SYS_SYSCALL_H
#include <mysql/mysql.h>
#include "zm_thread.h"
class Logger {
public:
enum {
@ -82,6 +84,8 @@ private:
static bool smInitialised;
static Logger *smInstance;
RecursiveMutex log_mutex;
static StringMap smCodes;
static IntMap smSyslogPriorities;