aboutsummaryrefslogtreecommitdiffstats
path: root/CommonLibs
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-06-04 00:09:29 -0400
committerTom Tsou <tom.tsou@ettus.com>2015-07-30 14:14:23 -0700
commit909ffbfd231aa716281c4b2948f2cd5e650237c0 (patch)
tree3a79403ef2c6e92e433979b98836af87a58807a9 /CommonLibs
parent351fd7670649cafd5344cf6fc746f63729df97cb (diff)
Common: Use a scoped lock in the Logger to avoid deadlock on thread cancel.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
Diffstat (limited to 'CommonLibs')
-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();
}
}