From 1ebba43052d68d874148e63c9ae38489ddfc5ec1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 15 Aug 2012 14:49:04 +1000 Subject: os: don't block signal-unsafe logging, merely warn about it. Throw an error into the log file, but continue anyway. And after three warnings, stop complaining. Not all input drivers will be fixed in time (or ever) and our printf implementation is vastly inferior, so there is still a use-case for non-sigsafe logging. This also adds more linebreaks to the message. CC: Chase Douglas Signed-off-by: Peter Hutterer Reviewed-by: Chase Douglas --- os/log.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/os/log.c b/os/log.c index 4348739d4..a0628fda3 100644 --- a/os/log.c +++ b/os/log.c @@ -467,6 +467,7 @@ LogMessageTypeVerbString(MessageType type, int verb) void LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) { + static unsigned int warned; const char *type_str; char buf[1024]; const size_t size = sizeof(buf); @@ -474,13 +475,17 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) size_t len = 0; if (inSignalContext) { - BUG_WARN_MSG(inSignalContext, - "Warning: attempting to log data in a signal unsafe " - "manner while in signal context. Please update to check " - "inSignalContext and/or use LogMessageVerbSigSafe() or " - "ErrorFSigSafe(). The offending log format message is:\n" - "%s\n", format); - return; + if (warned < 3) { + BUG_WARN_MSG(inSignalContext, + "Warning: attempting to log data in a signal unsafe " + "manner while in signal context.\nPlease update to check " + "inSignalContext and/or use LogMessageVerbSigSafe() or " + "ErrorFSigSafe().\nThe offending log format message is:\n" + "%s\n", format); + warned++; + if (warned == 3) + LogMessageVerbSigSafe(X_WARNING, -1, "Warned %u times about sigsafe logging. Will be quiet now.\n", warned); + } } type_str = LogMessageTypeVerbString(type, verb); @@ -566,6 +571,7 @@ void LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format, va_list msg_args, const char *hdr_format, va_list hdr_args) { + static unsigned int warned; const char *type_str; char buf[1024]; const size_t size = sizeof(buf); @@ -573,13 +579,17 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format, size_t len = 0; if (inSignalContext) { - BUG_WARN_MSG(inSignalContext, - "Warning: attempting to log data in a signal unsafe " - "manner while in signal context. Please update to check " - "inSignalContext and/or use LogMessageVerbSigSafe(). The " - "offending header and log message formats are:\n%s %s\n", - hdr_format, msg_format); - return; + if (warned < 3) { + BUG_WARN_MSG(inSignalContext, + "Warning: attempting to log data in a signal unsafe " + "manner while in signal context.\nPlease update to check " + "inSignalContext and/or use LogMessageVerbSigSafe().\nThe " + "offending header and log message formats are:\n%s %s\n", + hdr_format, msg_format); + warned++; + if (warned == 3) + LogMessageVerbSigSafe(X_WARNING, -1, "Warned %u times about sigsafe logging. Will be quiet now.\n", warned); + } } type_str = LogMessageTypeVerbString(type, verb); -- cgit v1.2.3