add a mutex in logging functions so that multiple threads can log at the same time
This commit is contained in:
parent
61759a1f2d
commit
4d4666f5e0
|
@ -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, ... ) {
|
void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) {
|
||||||
if ( level > mEffectiveLevel )
|
if ( level > mEffectiveLevel )
|
||||||
return;
|
return;
|
||||||
|
log_mutex.lock();
|
||||||
char timeString[64];
|
char timeString[64];
|
||||||
char logString[8192];
|
char logString[8192];
|
||||||
va_list argPtr;
|
va_list argPtr;
|
||||||
|
@ -579,6 +580,7 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
|
||||||
abort();
|
abort();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
log_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#endif // HAVE_SYS_SYSCALL_H
|
#endif // HAVE_SYS_SYSCALL_H
|
||||||
#include <mysql/mysql.h>
|
#include <mysql/mysql.h>
|
||||||
|
|
||||||
|
#include "zm_thread.h"
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
|
@ -82,6 +84,8 @@ private:
|
||||||
static bool smInitialised;
|
static bool smInitialised;
|
||||||
static Logger *smInstance;
|
static Logger *smInstance;
|
||||||
|
|
||||||
|
RecursiveMutex log_mutex;
|
||||||
|
|
||||||
static StringMap smCodes;
|
static StringMap smCodes;
|
||||||
static IntMap smSyslogPriorities;
|
static IntMap smSyslogPriorities;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue