Common: Use a scoped lock in the Logger to avoid deadlock on thread cancel.
This commit is contained in:
parent
351fd76706
commit
bbef7e4d70
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue