From 5db041adb700e4dc12aa168455a1c1dbf418029e Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 22 Feb 2024 20:48:35 +0100 Subject: [PATCH] impr: Make sure crashes during logging cannot cause a deadlock --- lib/libimhex/include/hex/helpers/logger.hpp | 2 +- lib/libimhex/source/helpers/logger.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libimhex/include/hex/helpers/logger.hpp b/lib/libimhex/include/hex/helpers/logger.hpp index 17f4aae1e..83ca8a604 100644 --- a/lib/libimhex/include/hex/helpers/logger.hpp +++ b/lib/libimhex/include/hex/helpers/logger.hpp @@ -19,7 +19,7 @@ namespace hex::log { [[maybe_unused]] void redirectToFile(); [[maybe_unused]] void enableColorPrinting(); - [[nodiscard]] std::mutex& getLoggerMutex(); + [[nodiscard]] std::recursive_mutex& getLoggerMutex(); [[nodiscard]] bool isLoggingSuspended(); struct LogEntry { diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp index 3c8b28b36..00bfcf50d 100644 --- a/lib/libimhex/source/helpers/logger.cpp +++ b/lib/libimhex/source/helpers/logger.cpp @@ -18,7 +18,7 @@ namespace hex::log { wolv::io::File s_loggerFile; bool s_colorOutputEnabled = false; - std::mutex s_loggerMutex; + std::recursive_mutex s_loggerMutex; bool s_loggingSuspended = false; } @@ -33,7 +33,7 @@ namespace hex::log { namespace impl { - std::mutex& getLoggerMutex() { + std::recursive_mutex& getLoggerMutex() { return s_loggerMutex; }