trylock was interesting for debugging, but really logging should wait for the lock
This commit is contained in:
parent
96a1ac14e8
commit
376e15b763
|
@ -536,7 +536,8 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
|
|||
char sql[ZM_SQL_MED_BUFSIZ];
|
||||
char escapedString[(strlen(syslogStart)*2)+1];
|
||||
|
||||
if ( ! db_mutex.trylock() ) {
|
||||
//if ( ! db_mutex.trylock() ) {
|
||||
db_mutex.lock();
|
||||
mysql_real_escape_string( &dbconn, escapedString, syslogStart, strlen(syslogStart) );
|
||||
|
||||
snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line );
|
||||
|
@ -547,12 +548,12 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
|
|||
databaseLevel(tempDatabaseLevel);
|
||||
}
|
||||
db_mutex.unlock();
|
||||
} else {
|
||||
Level tempDatabaseLevel = mDatabaseLevel;
|
||||
databaseLevel(NOLOG);
|
||||
Error("Can't insert log entry: sql(%s) error(db is locked)", logString);
|
||||
databaseLevel(tempDatabaseLevel);
|
||||
}
|
||||
///} else {
|
||||
///Level tempDatabaseLevel = mDatabaseLevel;
|
||||
///databaseLevel(NOLOG);
|
||||
///Error("Can't insert log entry: sql(%s) error(db is locked)", logString);
|
||||
///databaseLevel(tempDatabaseLevel);
|
||||
///}
|
||||
}
|
||||
if ( level <= mSyslogLevel ) {
|
||||
int priority = smSyslogPriorities[level];
|
||||
|
|
Loading…
Reference in New Issue