summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-17 19:57:13 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-17 19:57:46 +0100
commitc0f71f469fef3f3a0822e0021085e6d165df2b46 (patch)
treef58cab55abed9ac8c469ae85364be1f5c3f862d1
parent445ea9be520b9549aee45d0b6427cf48b446987f (diff)
journald: close /dev/kmsg again if we cannot make use of it
-rw-r--r--src/journal/journald-kmsg.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 1730a23a97..5c7c06a14a 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -408,22 +408,30 @@ int server_open_dev_kmsg(Server *s) {
/* This will fail with EPERM on older kernels where
* /dev/kmsg is not readable. */
- if (r == -EPERM)
- return 0;
+ if (r == -EPERM) {
+ r = 0;
+ goto fail;
+ }
log_error("Failed to add /dev/kmsg fd to event loop: %s", strerror(-r));
- return -errno;
+ goto fail;
}
r = sd_event_source_set_priority(s->dev_kmsg_event_source, SD_EVENT_PRIORITY_IMPORTANT+10);
if (r < 0) {
log_error("Failed to adjust priority of kmsg event source: %s", strerror(-r));
- return -errno;
+ goto fail;
}
s->dev_kmsg_readable = true;
return 0;
+
+fail:
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+
+ return r;
}
int server_open_kernel_seqnum(Server *s) {