teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0634-core-do-not-log-done-failed-condition-jobs-as-if-uni.patch

aed857
From 0fd062edc435d9cf39022e2e92c895bf8625ad0d Mon Sep 17 00:00:00 2001
aed857
From: Michal Schmidt <mschmidt@redhat.com>
aed857
Date: Tue, 21 Jul 2015 16:15:19 +0200
aed857
Subject: [PATCH] core: do not log done failed-condition jobs as if unit
aed857
 started
aed857
aed857
It is misleading to see "Started foo." in the log when the unit's
aed857
condition was false.
aed857
aed857
(cherry picked from commit 30961fa300cad21b50fe47baee523beeadb5d0bc)
aed857
aed857
Related: #1506256
aed857
---
aed857
 src/core/job.c | 26 +++++++++++++++-----------
aed857
 1 file changed, 15 insertions(+), 11 deletions(-)
aed857
aed857
diff --git a/src/core/job.c b/src/core/job.c
c62b8e
index f371f914d4..5e582b3d3c 100644
aed857
--- a/src/core/job.c
aed857
+++ b/src/core/job.c
aed857
@@ -692,13 +692,6 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) {
aed857
         assert(t >= 0);
aed857
         assert(t < _JOB_TYPE_MAX);
aed857
 
aed857
-        /* Reload status messages have traditionally not been printed to console. */
aed857
-        if (t == JOB_RELOAD)
aed857
-                return;
aed857
-
aed857
-        if (t == JOB_START && result == JOB_DONE && !u->condition_result)
aed857
-                return;
aed857
-
aed857
         format = job_get_status_message_format(u, t, result);
aed857
         if (!format)
aed857
                 return;
aed857
@@ -768,6 +761,19 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
aed857
                                 NULL);
aed857
 }
aed857
 
aed857
+static void job_emit_status_message(Unit *u, JobType t, JobResult result) {
aed857
+
aed857
+        /* No message if the job did not actually do anything due to failed condition. */
aed857
+        if (t == JOB_START && result == JOB_DONE && !u->condition_result)
aed857
+                return;
aed857
+
aed857
+        job_log_status_message(u, t, result);
aed857
+
aed857
+        /* Reload status messages have traditionally not been printed to console. */
aed857
+        if (t != JOB_RELOAD)
aed857
+                job_print_status_message(u, t, result);
aed857
+}
aed857
+
aed857
 int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool already) {
aed857
         Unit *u;
aed857
         Unit *other;
aed857
@@ -787,10 +793,8 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr
aed857
                        u->id, job_type_to_string(t), job_result_to_string(result));
aed857
 
aed857
         /* If this job did nothing to respective unit we don't log the status message */
aed857
-        if (!already) {
aed857
-                job_print_status_message(u, t, result);
aed857
-                job_log_status_message(u, t, result);
aed857
-        }
aed857
+        if (!already)
aed857
+                job_emit_status_message(u, t, result);
aed857
 
aed857
         job_add_to_dbus_queue(j);
aed857