浏览代码

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 月之前
父节点
当前提交
eea90f52ce
共有 1 个文件被更改,包括 3 次插入1 次删除
  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 "";
     }