From bbef7e4d7034e172a75dd1d2b46c5de7dc223c9c Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Thu, 4 Jun 2015 00:09:29 -0400 Subject: Common: Use a scoped lock in the Logger to avoid deadlock on thread cancel. --- CommonLibs/Logger.cpp | 3 +-- 1 file changed, 1 insertion(+), 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(); } } -- cgit v1.2.3