summaryrefslogtreecommitdiff
path: root/src/basic/log.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-22 00:31:36 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:59:02 +0200
commit8b1de0ce2cd30cf60f8129c84b4ea64e612e97eb (patch)
treef93ca8e6c1c0bc857d7887fc0603889790fcafb4 /src/basic/log.c
parentc184fc5282e2d262974e84affb1e481fb0ee56b4 (diff)
log: only open kmsg on fallback if we actually want to use it
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...
Diffstat (limited to 'src/basic/log.c')
-rw-r--r--src/basic/log.c17
1 files changed, 7 insertions, 10 deletions
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();