teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0139-journal-fail-silently-in-sd_j_sendv-if-journal-is-un.patch

Zbigniew Jędrzejewski-Szmek d66047
From 9c6964b0a23852353aaa0ca0c30586c3f19502b7 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek d66047
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Zbigniew Jędrzejewski-Szmek d66047
Date: Tue, 3 Dec 2013 08:07:32 -0500
Zbigniew Jędrzejewski-Szmek d66047
Subject: [PATCH] journal: fail silently in sd_j_sendv() if journal is
Zbigniew Jędrzejewski-Szmek d66047
 unavailable
Zbigniew Jędrzejewski-Szmek d66047
Zbigniew Jędrzejewski-Szmek d66047
"syslog(3) and sd_journal_print() may largely be used interchangeably
Zbigniew Jędrzejewski-Szmek d66047
functionality-wise" according to sd_journal_print(3). This socket
Zbigniew Jędrzejewski-Szmek d66047
should be always available except in rare circumstatances, and we
Zbigniew Jędrzejewski-Szmek d66047
don't random applications to fail on logging, so let's do what syslog
Zbigniew Jędrzejewski-Szmek d66047
did. The alternative of forcing all callers to do error handling for
Zbigniew Jędrzejewski-Szmek d66047
this rare case doesn't really have any benefits, since if they can't
Zbigniew Jędrzejewski-Szmek d66047
log there isn't much they can do anyway.
Zbigniew Jędrzejewski-Szmek d66047
Zbigniew Jędrzejewski-Szmek d66047
https://bugzilla.redhat.com/show_bug.cgi?id=1023041
Zbigniew Jędrzejewski-Szmek d66047
---
Zbigniew Jędrzejewski-Szmek d66047
 src/journal/journal-send.c | 4 ++++
Zbigniew Jędrzejewski-Szmek d66047
 1 file changed, 4 insertions(+)
Zbigniew Jędrzejewski-Szmek d66047
Zbigniew Jędrzejewski-Szmek d66047
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
Zbigniew Jędrzejewski-Szmek d66047
index d00e26f..d99ff0c 100644
Zbigniew Jędrzejewski-Szmek d66047
--- a/src/journal/journal-send.c
Zbigniew Jędrzejewski-Szmek d66047
+++ b/src/journal/journal-send.c
Zbigniew Jędrzejewski-Szmek d66047
@@ -305,6 +305,10 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
Zbigniew Jędrzejewski-Szmek d66047
         if (k >= 0)
Zbigniew Jędrzejewski-Szmek d66047
                 return 0;
Zbigniew Jędrzejewski-Szmek d66047
 
Zbigniew Jędrzejewski-Szmek d66047
+        /* Fail silently if the journal is not available */
Zbigniew Jędrzejewski-Szmek d66047
+        if (errno == ENOENT)
Zbigniew Jędrzejewski-Szmek d66047
+                return 0;
Zbigniew Jędrzejewski-Szmek d66047
+
Zbigniew Jędrzejewski-Szmek d66047
         if (errno != EMSGSIZE && errno != ENOBUFS)
Zbigniew Jędrzejewski-Szmek d66047
                 return -errno;
Zbigniew Jędrzejewski-Szmek d66047