Explorar o código

Fix logging deadlock in levelToSystemdPriority()

The levelToSystemdPriority() function was calling isRunningUnderSystemd()
which tried to acquire the same mutex that was already locked in the log()
method, causing a deadlock and preventing any log output.

Fixed by directly checking the m_isRunningUnderSystemd member variable
instead of calling isRunningUnderSystemd() to avoid the recursive mutex
lock.

This resolves the issue where no log output appeared when running the
server in terminal (not systemd) even with the --verbose flag.
Fszontagh hai 3 meses
pai
achega
eea90f52ce
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/logger.cpp

+ 3 - 1
src/logger.cpp

@@ -96,7 +96,9 @@ std::string Logger::typeToString(LoggerType type) {
 
 std::string Logger::levelToSystemdPriority(LogLevel level) {
     // Only include priority markers when running under systemd
-    if (!isRunningUnderSystemd()) {
+    // Note: Don't call isRunningUnderSystemd() here to avoid deadlock
+    // since this method is called from within the log() method which already holds the mutex
+    if (!m_isRunningUnderSystemd) {
         return "";
     }