From 13df29f01f1fe9a90b08e11a75354845e86dfd58 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Mon, 16 Jan 2017 13:59:11 +0100 Subject: [PATCH] Use recursive mutex on log calls because some call arguments can themselves call the log. Caused actual deadlocks in recoll 1.23 GUI with high verbosity --- src/utils/log.cpp | 2 +- src/utils/log.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/log.cpp b/src/utils/log.cpp index d98efe15..7b62248a 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -31,7 +31,7 @@ Logger::Logger(const std::string& fn) bool Logger::reopen(const std::string& fn) { #if LOGGER_THREADSAFE - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); #endif if (!fn.empty()) { m_fn = fn; diff --git a/src/utils/log.h b/src/utils/log.h index d4ef403d..1060ab4a 100644 --- a/src/utils/log.h +++ b/src/utils/log.h @@ -73,7 +73,7 @@ public: } #if LOGGER_THREADSAFE - std::mutex& getmutex() { + std::recursive_mutex& getmutex() { return m_mutex; } #endif @@ -84,7 +84,7 @@ private: std::string m_fn; std::ofstream m_stream; #if LOGGER_THREADSAFE - std::mutex m_mutex; + std::recursive_mutex m_mutex; #endif Logger(const std::string& fn); @@ -96,7 +96,7 @@ private: #if LOGGER_THREADSAFE #define LOGGER_LOCK \ - std::unique_lock lock(Logger::getTheLog("")->getmutex()) + std::unique_lock lock(Logger::getTheLog("")->getmutex()) #else #define LOGGER_LOCK #endif