(!1688) 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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-09-09 20:53:17 +02:00
parent ba8c048b3a
commit 6b0fc3eb40
3 changed files with 12 additions and 5 deletions

View File

@ -831,7 +831,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
}
else if (!xf86NameCmp(s, "sync")) {
xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
LogSetParameter(XLOG_SYNC, TRUE);
xorgLogSync = TRUE;
}
else {
xf86Msg(X_WARNING, "Unknown Log option\n");

View File

@ -122,7 +122,7 @@ void (*OsVendorVErrorFProc) (const char *, va_list args) = NULL;
#endif
static int logFileFd = -1;
static Bool logSync = FALSE;
Bool xorgLogSync = FALSE;
int xorgLogVerbosity = DEFAULT_LOG_VERBOSITY;
int xorgLogFileVerbosity = DEFAULT_LOG_FILE_VERBOSITY;
@ -349,7 +349,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;
@ -607,7 +607,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) {
@ -626,7 +626,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) {

View File

@ -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 */