teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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