From 2a32187a38acedf34c553d060434038f838d1024 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 9 Sep 2024 20:53:17 +0200 Subject: [PATCH] os: directly set log file sync flag, instead of using LogSetParameter() No need for extra call to some demuxer function for nothing but setting a simple bool variable. Setting the sync flag really is nothing more than just writing some value into a variable, so it's trivial to just to do that, instead of having an unncessarily complex "universal setter" for that. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86Config.c | 2 +- os/log.c | 8 ++++---- os/log_priv.h | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 59ab8d511..d85898b91 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -828,7 +828,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) } else if (!xf86NameCmp(s, "sync")) { LogMessageVerb(X_CONFIG, 1, "Syncing logfile enabled\n"); - LogSetParameter(XLOG_SYNC, TRUE); + xorgLogSync = TRUE; } else { LogMessageVerb(X_WARNING, 1, "Unknown Log option\n"); diff --git a/os/log.c b/os/log.c index 5aaccb109..ac547efed 100644 --- a/os/log.c +++ b/os/log.c @@ -112,7 +112,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #define DEFAULT_LOG_FILE_VERBOSITY 3 static int logFileFd = -1; -static Bool logSync = FALSE; +Bool xorgLogSync = FALSE; int xorgLogVerbosity = DEFAULT_LOG_VERBOSITY; int xorgLogFileVerbosity = DEFAULT_LOG_FILE_VERBOSITY; @@ -315,7 +315,7 @@ LogSetParameter(LogParameter param, int value) { switch (param) { case XLOG_SYNC: - logSync = value ? TRUE : FALSE; + xorgLogSync = value ? TRUE : FALSE; return TRUE; case XLOG_VERBOSITY: xorgLogVerbosity = value; @@ -561,7 +561,7 @@ LogSWrite(int verb, const char *buf, size_t len, Bool end_line) if (verb < 0 || xorgLogFileVerbosity >= verb) { if (inSignalContext && logFileFd >= 0) { ret = write(logFileFd, buf, len); - if (logSync) + if (xorgLogSync) doLogSync(); } else if (!inSignalContext && logFileFd != -1) { @@ -576,7 +576,7 @@ LogSWrite(int verb, const char *buf, size_t len, Bool end_line) } newline = end_line; write(logFileFd, buf, len); - if (logSync) + if (xorgLogSync) doLogSync(); } else if (!inSignalContext && needBuffer) { diff --git a/os/log_priv.h b/os/log_priv.h index 28f6fb26c..e83ec6cee 100644 --- a/os/log_priv.h +++ b/os/log_priv.h @@ -84,4 +84,11 @@ extern int xorgLogVerbosity; */ extern int xorgLogFileVerbosity; +/** + * @brief force fsync() on each log write + * + * If set to TRUE, force fsync() on each log write. + */ +extern Bool xorgLogSync; + #endif /* __XORG_OS_LOGGING_H */