Forráskód Böngészése

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 3 hónapja
szülő
commit
eea90f52ce
1 módosított fájl, 3 hozzáadás és 1 törlés
  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 "";
     }