Common: Use a scoped lock in the Logger to avoid deadlock on thread cancel.

This commit is contained in:
Alexander Chemeris 2015-06-04 00:09:29 -04:00
parent 351fd76706
commit bbef7e4d70
1 changed files with 1 additions and 2 deletions

View File

@ -206,7 +206,7 @@ Log::~Log()
if (gLogToConsole||gLogToFile) {
int mlen = mStream.str().size();
int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
gLogToLock.lock();
ScopedLock lock(gLogToLock);
if (gLogToConsole) {
// The COUT() macro prevents messages from stomping each other but adds uninteresting thread numbers,
// so just use std::cout.
@ -218,7 +218,6 @@ Log::~Log()
if (neednl) {fputc('\n',gLogToFile);}
fflush(gLogToFile);
}
gLogToLock.unlock();
}
}