From 8b1de0ce2cd30cf60f8129c84b4ea64e612e97eb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 22 Feb 2018 00:31:36 +0100 Subject: log: only open kmsg on fallback if we actually want to use it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, we'd try to open kmsg on failure of the journal/syslog even if no automatic fallback to kmsg was requested — and we wouldn't even use the open connection afterwards... --- src/basic/log.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/basic/log.c') diff --git a/src/basic/log.c b/src/basic/log.c index 3963e0371..c0117f692 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -628,11 +628,8 @@ int log_dispatch_internal( LOG_TARGET_JOURNAL)) { k = write_to_journal(level, error, file, line, func, object_field, object, extra_field, extra, buffer); - if (k < 0) { - if (k != -EAGAIN) - log_close_journal(); - log_open_kmsg(); - } + if (k < 0 && k != -EAGAIN) + log_close_journal(); } #endif // 0 @@ -640,11 +637,8 @@ int log_dispatch_internal( LOG_TARGET_SYSLOG)) { k = write_to_syslog(level, error, file, line, func, buffer); - if (k < 0) { - if (k != -EAGAIN) - log_close_syslog(); - log_open_kmsg(); - } + if (k < 0 && k != -EAGAIN) + log_close_syslog(); } if (k <= 0 && @@ -653,6 +647,9 @@ int log_dispatch_internal( LOG_TARGET_JOURNAL_OR_KMSG, LOG_TARGET_KMSG)) { + if (k < 0) + log_open_kmsg(); + k = write_to_kmsg(level, error, file, line, func, buffer); if (k < 0) { log_close_kmsg(); -- cgit v1.2.3