aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-06-04 00:09:29 -0400
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-06-04 19:13:48 -0400
commitbbef7e4d7034e172a75dd1d2b46c5de7dc223c9c (patch)
tree3a79403ef2c6e92e433979b98836af87a58807a9
parent351fd7670649cafd5344cf6fc746f63729df97cb (diff)
Common: Use a scoped lock in the Logger to avoid deadlock on thread cancel.
-rw-r--r--CommonLibs/Logger.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 04a7ae4..2a53698 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -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();
}
}