anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

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

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