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 <chase.douglas@canonical.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
parent
4912b4adb6
commit
1ebba43052
38
os/log.c
38
os/log.c
|
@ -467,6 +467,7 @@ LogMessageTypeVerbString(MessageType type, int verb)
|
||||||
void
|
void
|
||||||
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
|
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
|
static unsigned int warned;
|
||||||
const char *type_str;
|
const char *type_str;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
const size_t size = sizeof(buf);
|
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;
|
size_t len = 0;
|
||||||
|
|
||||||
if (inSignalContext) {
|
if (inSignalContext) {
|
||||||
BUG_WARN_MSG(inSignalContext,
|
if (warned < 3) {
|
||||||
"Warning: attempting to log data in a signal unsafe "
|
BUG_WARN_MSG(inSignalContext,
|
||||||
"manner while in signal context. Please update to check "
|
"Warning: attempting to log data in a signal unsafe "
|
||||||
"inSignalContext and/or use LogMessageVerbSigSafe() or "
|
"manner while in signal context.\nPlease update to check "
|
||||||
"ErrorFSigSafe(). The offending log format message is:\n"
|
"inSignalContext and/or use LogMessageVerbSigSafe() or "
|
||||||
"%s\n", format);
|
"ErrorFSigSafe().\nThe offending log format message is:\n"
|
||||||
return;
|
"%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);
|
type_str = LogMessageTypeVerbString(type, verb);
|
||||||
|
@ -566,6 +571,7 @@ void
|
||||||
LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
|
LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
|
||||||
va_list msg_args, const char *hdr_format, va_list hdr_args)
|
va_list msg_args, const char *hdr_format, va_list hdr_args)
|
||||||
{
|
{
|
||||||
|
static unsigned int warned;
|
||||||
const char *type_str;
|
const char *type_str;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
const size_t size = sizeof(buf);
|
const size_t size = sizeof(buf);
|
||||||
|
@ -573,13 +579,17 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
if (inSignalContext) {
|
if (inSignalContext) {
|
||||||
BUG_WARN_MSG(inSignalContext,
|
if (warned < 3) {
|
||||||
"Warning: attempting to log data in a signal unsafe "
|
BUG_WARN_MSG(inSignalContext,
|
||||||
"manner while in signal context. Please update to check "
|
"Warning: attempting to log data in a signal unsafe "
|
||||||
"inSignalContext and/or use LogMessageVerbSigSafe(). The "
|
"manner while in signal context.\nPlease update to check "
|
||||||
"offending header and log message formats are:\n%s %s\n",
|
"inSignalContext and/or use LogMessageVerbSigSafe().\nThe "
|
||||||
hdr_format, msg_format);
|
"offending header and log message formats are:\n%s %s\n",
|
||||||
return;
|
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);
|
type_str = LogMessageTypeVerbString(type, verb);
|
||||||
|
|
Loading…
Reference in New Issue