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, ... ) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue