Blame SOURCES/0630-core-always-try-harder-to-get-unit-status-message-fo.patch

17b0f1
From c571dc5f7d593a4526da9e19b35ae3d1ed11bfaa Mon Sep 17 00:00:00 2001
17b0f1
From: Michal Schmidt <mschmidt@redhat.com>
17b0f1
Date: Mon, 20 Jul 2015 17:18:13 +0200
17b0f1
Subject: [PATCH] core: always try harder to get unit status message format
17b0f1
 string
17b0f1
17b0f1
The starting/stopping messages are printed to the console only if the
17b0f1
corresponding format string is defined in the unit's vtable. To avoid
17b0f1
excessive messages on the console, the unit types whose start/stop
17b0f1
jobs are instantaneous had the format strings intentionally undefined.
17b0f1
When logging the same event to the journal, a fallback to generic
17b0f1
Starting/Stopping/Reloading messages is used.
17b0f1
17b0f1
The problem of excessive console messages with instantaneous jobs
17b0f1
is already resolved in a nicer way ("core: fix confusing logging of
17b0f1
instantaneous jobs"), so there's no longer a need to have two ways of
17b0f1
getting the format strings. Let's fold them into one function with
17b0f1
the fallback to generic message strings.
17b0f1
17b0f1
(cherry picked from commit a85ca902c9f7f5aa8f2f3e3299147733802cf09d)
17b0f1
17b0f1
Related: #1506256
17b0f1
---
17b0f1
 src/core/unit.c | 34 ++++++++++------------------------
17b0f1
 1 file changed, 10 insertions(+), 24 deletions(-)
17b0f1
17b0f1
diff --git a/src/core/unit.c b/src/core/unit.c
17b0f1
index 907a4bf7fd..a33cbdf73f 100644
17b0f1
--- a/src/core/unit.c
17b0f1
+++ b/src/core/unit.c
17b0f1
@@ -1328,32 +1328,21 @@ static bool unit_assert_test(Unit *u) {
17b0f1
 }
17b0f1
 
17b0f1
 _pure_ static const char* unit_get_status_message_format(Unit *u, JobType t) {
17b0f1
-        const UnitStatusMessageFormats *format_table;
17b0f1
-
17b0f1
-        assert(u);
17b0f1
-        assert(t >= 0);
17b0f1
-        assert(t < _JOB_TYPE_MAX);
17b0f1
-
17b0f1
-        if (t != JOB_START && t != JOB_STOP)
17b0f1
-                return NULL;
17b0f1
-
17b0f1
-        format_table = &UNIT_VTABLE(u)->status_message_formats;
17b0f1
-        if (!format_table)
17b0f1
-                return NULL;
17b0f1
-
17b0f1
-        return format_table->starting_stopping[t == JOB_STOP];
17b0f1
-}
17b0f1
-
17b0f1
-_pure_ static const char *unit_get_status_message_format_try_harder(Unit *u, JobType t) {
17b0f1
         const char *format;
17b0f1
+        const UnitStatusMessageFormats *format_table;
17b0f1
 
17b0f1
         assert(u);
17b0f1
         assert(t >= 0);
17b0f1
         assert(t < _JOB_TYPE_MAX);
17b0f1
 
17b0f1
-        format = unit_get_status_message_format(u, t);
17b0f1
-        if (format)
17b0f1
-                return format;
17b0f1
+        if (t == JOB_START || t == JOB_STOP) {
17b0f1
+                format_table = &UNIT_VTABLE(u)->status_message_formats;
17b0f1
+                if (format_table) {
17b0f1
+                        format = format_table->starting_stopping[t == JOB_STOP];
17b0f1
+                        if (format)
17b0f1
+                                return format;
17b0f1
+                }
17b0f1
+        }
17b0f1
 
17b0f1
         /* Return generic strings */
17b0f1
         if (t == JOB_START)
17b0f1
@@ -1371,9 +1360,6 @@ static void unit_status_print_starting_stopping(Unit *u, JobType t) {
17b0f1
 
17b0f1
         assert(u);
17b0f1
 
17b0f1
-        /* We only print status messages for selected units on
17b0f1
-         * selected operations. */
17b0f1
-
17b0f1
         format = unit_get_status_message_format(u, t);
17b0f1
         if (!format)
17b0f1
                 return;
17b0f1
@@ -1398,7 +1384,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
17b0f1
 
17b0f1
         /* We log status messages for all units and all operations. */
17b0f1
 
17b0f1
-        format = unit_get_status_message_format_try_harder(u, t);
17b0f1
+        format = unit_get_status_message_format(u, t);
17b0f1
         if (!format)
17b0f1
                 return;
17b0f1