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

This commit is contained in:
Jean-Francois Dockes 2017-01-16 13:59:11 +01:00
parent 35d92714d9
commit 13df29f01f
2 changed files with 4 additions and 4 deletions

View file

@ -31,7 +31,7 @@ Logger::Logger(const std::string& fn)
bool Logger::reopen(const std::string& fn)
{
#if LOGGER_THREADSAFE
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<std::recursive_mutex> lock(m_mutex);
#endif
if (!fn.empty()) {
m_fn = fn;

View file

@ -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<std::mutex> lock(Logger::getTheLog("")->getmutex())
std::unique_lock<std::recursive_mutex> lock(Logger::getTheLog("")->getmutex())
#else
#define LOGGER_LOCK
#endif