Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address mixed use of ldmsd_log() and ovis_log() #1481

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

nichamon
Copy link
Collaborator

The pull request resolves #1471 .

The majority of the code uses ldmsd_log(), but a few ldmsd plugins and
the authentication plugins use ovis_log(). This mixed use of logging
functions creates a possibility of message interleaving. ovis_log()
prints to stdout, and both functions write to the same FILE* stream as
ldmsd sets stdout to the log file.

Modified both functions to use a single fprintf() call per log message
instead of multiple calls. While this doesn't eliminate the possibility
of message interleaving between threads, consolidating to a single
fprintf() per message reduces the opportunities for interruption
compared to multiple fprintf() calls.
The loglevel command now affects the default verbosity of messages
logged through ovis_log() not only ldmsd_log(). Previously, users could
only control the verbosity of messages logged through ldmsd_log(), while
ovis_log() messages were unaffected by the loglevel setting.
@@ -945,6 +940,8 @@ int ovis_vlog(ovis_log_t log, int level, const char *fmt, va_list ap)
/* No workers, so directly log to the file. */
rc = __log(log, level, msg, &tv, &tm);
free(msg);
if (log_fp != OVIS_LOG_SYSLOG)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this condition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if-statement prevents calling fflush() on an invalid FILE * stream, which is OVIS_LOG_SYSLOG (0x7).

When ovis_log_open() is called with syslog as the path, I set log_fp to OVIS_LOG_SYSLOG. After investigation, I believe a better approach would be to let applications specify syslog output during initialization through the modes argument of the ovis_log_init() function. Since modes is a mask, we could add a new flag for syslog support. Then, the if-statement will check if the syslog mode is enabled.

The patch is going into b4.4. If we agree on chaning the syslog handling in ovis_log, I could implement the change for the top of tree.

@tom95858 tom95858 merged commit bfd5824 into ovis-hpc:b4.4 Oct 28, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants