richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
8d86bd
From f1a1ff976ed0787c79a0f57d773bc555ab756b8c Mon Sep 17 00:00:00 2001
8d86bd
From: Daan De Meyer <daan.j.demeyer@gmail.com>
8d86bd
Date: Fri, 17 Dec 2021 19:39:29 +0100
8d86bd
Subject: [PATCH] Revert "core: Propagate condition failed state to triggering
8d86bd
 units."
8d86bd
8d86bd
This reverts commit 12ab94a1e4961a39c32efb60b71866ab588d3ea2.
8d86bd
8d86bd
(cherry picked from commit 40f41f34d4af15d0147b5b2525f0b87ff62eae9a)
8d86bd
8d86bd
Related: #2114005
8d86bd
---
8d86bd
 src/core/automount.c | 14 ++++----------
8d86bd
 src/core/automount.h |  1 -
8d86bd
 src/core/path.c      | 16 +++++-----------
8d86bd
 src/core/path.h      |  1 -
8d86bd
 src/core/socket.c    | 28 +++++++++-------------------
8d86bd
 src/core/socket.h    |  1 -
8d86bd
 src/core/timer.c     | 12 +++---------
8d86bd
 src/core/timer.h     |  1 -
8d86bd
 src/core/unit.c      | 10 ----------
8d86bd
 src/core/unit.h      |  2 --
8d86bd
 10 files changed, 21 insertions(+), 65 deletions(-)
8d86bd
8d86bd
diff --git a/src/core/automount.c b/src/core/automount.c
8d86bd
index bac3b2fab7..c1c513d4a5 100644
8d86bd
--- a/src/core/automount.c
8d86bd
+++ b/src/core/automount.c
8d86bd
@@ -776,11 +776,6 @@ static void automount_enter_running(Automount *a) {
8d86bd
                 goto fail;
8d86bd
         }
8d86bd
 
8d86bd
-        if (unit_has_failed_condition_or_assert(trigger)) {
8d86bd
-                automount_enter_dead(a, AUTOMOUNT_FAILURE_MOUNT_CONDITION_FAILED);
8d86bd
-                return;
8d86bd
-        }
8d86bd
-
8d86bd
         r = manager_add_job(UNIT(a)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
8d86bd
         if (r < 0) {
8d86bd
                 log_unit_warning(UNIT(a), "Failed to queue mount startup job: %s", bus_error_message(&error, r));
8d86bd
@@ -1092,11 +1087,10 @@ static int automount_can_start(Unit *u) {
8d86bd
 }
8d86bd
 
8d86bd
 static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = {
8d86bd
-        [AUTOMOUNT_SUCCESS]                        = "success",
8d86bd
-        [AUTOMOUNT_FAILURE_RESOURCES]              = "resources",
8d86bd
-        [AUTOMOUNT_FAILURE_START_LIMIT_HIT]        = "start-limit-hit",
8d86bd
-        [AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT]  = "mount-start-limit-hit",
8d86bd
-        [AUTOMOUNT_FAILURE_MOUNT_CONDITION_FAILED] = "mount-condition-failed",
8d86bd
+        [AUTOMOUNT_SUCCESS] = "success",
8d86bd
+        [AUTOMOUNT_FAILURE_RESOURCES] = "resources",
8d86bd
+        [AUTOMOUNT_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
8d86bd
+        [AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT] = "mount-start-limit-hit",
8d86bd
 };
8d86bd
 
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
8d86bd
diff --git a/src/core/automount.h b/src/core/automount.h
8d86bd
index a7417d195c..21dd1c0774 100644
8d86bd
--- a/src/core/automount.h
8d86bd
+++ b/src/core/automount.h
8d86bd
@@ -10,7 +10,6 @@ typedef enum AutomountResult {
8d86bd
         AUTOMOUNT_FAILURE_RESOURCES,
8d86bd
         AUTOMOUNT_FAILURE_START_LIMIT_HIT,
8d86bd
         AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT,
8d86bd
-        AUTOMOUNT_FAILURE_MOUNT_CONDITION_FAILED,
8d86bd
         _AUTOMOUNT_RESULT_MAX,
8d86bd
         _AUTOMOUNT_RESULT_INVALID = -1
8d86bd
 } AutomountResult;
8d86bd
diff --git a/src/core/path.c b/src/core/path.c
8d86bd
index bf7e1bf3c2..c2facf0b16 100644
8d86bd
--- a/src/core/path.c
8d86bd
+++ b/src/core/path.c
8d86bd
@@ -453,7 +453,7 @@ static void path_enter_dead(Path *p, PathResult f) {
8d86bd
         else
8d86bd
                 unit_log_failure(UNIT(p), path_result_to_string(p->result));
8d86bd
 
8d86bd
-        path_set_state(p, p->result == PATH_SUCCESS ? PATH_DEAD : PATH_FAILED);
8d86bd
+        path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD);
8d86bd
 }
8d86bd
 
8d86bd
 static void path_enter_running(Path *p) {
8d86bd
@@ -711,11 +711,6 @@ static void path_trigger_notify(Unit *u, Unit *other) {
8d86bd
                 return;
8d86bd
         }
8d86bd
 
8d86bd
-        if (unit_has_failed_condition_or_assert(other)) {
8d86bd
-                path_enter_dead(p, PATH_FAILURE_UNIT_CONDITION_FAILED);
8d86bd
-                return;
8d86bd
-        }
8d86bd
-
8d86bd
         /* Don't propagate anything if there's still a job queued */
8d86bd
         if (other->job)
8d86bd
                 return;
8d86bd
@@ -768,11 +763,10 @@ static const char* const path_type_table[_PATH_TYPE_MAX] = {
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(path_type, PathType);
8d86bd
 
8d86bd
 static const char* const path_result_table[_PATH_RESULT_MAX] = {
8d86bd
-        [PATH_SUCCESS]                       = "success",
8d86bd
-        [PATH_FAILURE_RESOURCES]             = "resources",
8d86bd
-        [PATH_FAILURE_START_LIMIT_HIT]       = "start-limit-hit",
8d86bd
-        [PATH_FAILURE_UNIT_START_LIMIT_HIT]  = "unit-start-limit-hit",
8d86bd
-        [PATH_FAILURE_UNIT_CONDITION_FAILED] = "unit-condition-failed",
8d86bd
+        [PATH_SUCCESS] = "success",
8d86bd
+        [PATH_FAILURE_RESOURCES] = "resources",
8d86bd
+        [PATH_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
8d86bd
+        [PATH_FAILURE_UNIT_START_LIMIT_HIT] = "unit-start-limit-hit",
8d86bd
 };
8d86bd
 
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult);
8d86bd
diff --git a/src/core/path.h b/src/core/path.h
8d86bd
index 0ad6bd12c6..8a69f06c13 100644
8d86bd
--- a/src/core/path.h
8d86bd
+++ b/src/core/path.h
8d86bd
@@ -46,7 +46,6 @@ typedef enum PathResult {
8d86bd
         PATH_FAILURE_RESOURCES,
8d86bd
         PATH_FAILURE_START_LIMIT_HIT,
8d86bd
         PATH_FAILURE_UNIT_START_LIMIT_HIT,
8d86bd
-        PATH_FAILURE_UNIT_CONDITION_FAILED,
8d86bd
         _PATH_RESULT_MAX,
8d86bd
         _PATH_RESULT_INVALID = -1
8d86bd
 } PathResult;
8d86bd
diff --git a/src/core/socket.c b/src/core/socket.c
8d86bd
index bdfeb43a70..9d47ca2616 100644
8d86bd
--- a/src/core/socket.c
8d86bd
+++ b/src/core/socket.c
8d86bd
@@ -2274,15 +2274,6 @@ static void socket_enter_running(Socket *s, int cfd) {
8d86bd
                 goto refuse;
8d86bd
         }
8d86bd
 
8d86bd
-        if (UNIT_ISSET(s->service) && cfd < 0) {
8d86bd
-                Unit *service = UNIT_DEREF(s->service);
8d86bd
-
8d86bd
-                if (unit_has_failed_condition_or_assert(service)) {
8d86bd
-                        socket_enter_dead(s, SOCKET_FAILURE_SERVICE_CONDITION_FAILED);
8d86bd
-                        return;
8d86bd
-                }
8d86bd
-        }
8d86bd
-
8d86bd
         if (cfd < 0) {
8d86bd
                 bool pending = false;
8d86bd
                 Unit *other;
8d86bd
@@ -3298,16 +3289,15 @@ static const char* const socket_exec_command_table[_SOCKET_EXEC_COMMAND_MAX] = {
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(socket_exec_command, SocketExecCommand);
8d86bd
 
8d86bd
 static const char* const socket_result_table[_SOCKET_RESULT_MAX] = {
8d86bd
-        [SOCKET_SUCCESS]                          = "success",
8d86bd
-        [SOCKET_FAILURE_RESOURCES]                = "resources",
8d86bd
-        [SOCKET_FAILURE_TIMEOUT]                  = "timeout",
8d86bd
-        [SOCKET_FAILURE_EXIT_CODE]                = "exit-code",
8d86bd
-        [SOCKET_FAILURE_SIGNAL]                   = "signal",
8d86bd
-        [SOCKET_FAILURE_CORE_DUMP]                = "core-dump",
8d86bd
-        [SOCKET_FAILURE_START_LIMIT_HIT]          = "start-limit-hit",
8d86bd
-        [SOCKET_FAILURE_TRIGGER_LIMIT_HIT]        = "trigger-limit-hit",
8d86bd
-        [SOCKET_FAILURE_SERVICE_START_LIMIT_HIT]  = "service-start-limit-hit",
8d86bd
-        [SOCKET_FAILURE_SERVICE_CONDITION_FAILED] = "service-condition-failed",
8d86bd
+        [SOCKET_SUCCESS] = "success",
8d86bd
+        [SOCKET_FAILURE_RESOURCES] = "resources",
8d86bd
+        [SOCKET_FAILURE_TIMEOUT] = "timeout",
8d86bd
+        [SOCKET_FAILURE_EXIT_CODE] = "exit-code",
8d86bd
+        [SOCKET_FAILURE_SIGNAL] = "signal",
8d86bd
+        [SOCKET_FAILURE_CORE_DUMP] = "core-dump",
8d86bd
+        [SOCKET_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
8d86bd
+        [SOCKET_FAILURE_TRIGGER_LIMIT_HIT] = "trigger-limit-hit",
8d86bd
+        [SOCKET_FAILURE_SERVICE_START_LIMIT_HIT] = "service-start-limit-hit"
8d86bd
 };
8d86bd
 
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(socket_result, SocketResult);
8d86bd
diff --git a/src/core/socket.h b/src/core/socket.h
8d86bd
index b171b94316..2409dbf2a0 100644
8d86bd
--- a/src/core/socket.h
8d86bd
+++ b/src/core/socket.h
8d86bd
@@ -39,7 +39,6 @@ typedef enum SocketResult {
8d86bd
         SOCKET_FAILURE_START_LIMIT_HIT,
8d86bd
         SOCKET_FAILURE_TRIGGER_LIMIT_HIT,
8d86bd
         SOCKET_FAILURE_SERVICE_START_LIMIT_HIT,
8d86bd
-        SOCKET_FAILURE_SERVICE_CONDITION_FAILED,
8d86bd
         _SOCKET_RESULT_MAX,
8d86bd
         _SOCKET_RESULT_INVALID = -1
8d86bd
 } SocketResult;
8d86bd
diff --git a/src/core/timer.c b/src/core/timer.c
8d86bd
index 3c8d89771d..990f05fee4 100644
8d86bd
--- a/src/core/timer.c
8d86bd
+++ b/src/core/timer.c
8d86bd
@@ -567,11 +567,6 @@ static void timer_enter_running(Timer *t) {
8d86bd
                 return;
8d86bd
         }
8d86bd
 
8d86bd
-        if (unit_has_failed_condition_or_assert(trigger)) {
8d86bd
-                timer_enter_dead(t, TIMER_FAILURE_UNIT_CONDITION_FAILED);
8d86bd
-                return;
8d86bd
-        }
8d86bd
-
8d86bd
         r = manager_add_job(UNIT(t)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
8d86bd
         if (r < 0)
8d86bd
                 goto fail;
8d86bd
@@ -855,10 +850,9 @@ static const char* const timer_base_table[_TIMER_BASE_MAX] = {
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(timer_base, TimerBase);
8d86bd
 
8d86bd
 static const char* const timer_result_table[_TIMER_RESULT_MAX] = {
8d86bd
-        [TIMER_SUCCESS]                       = "success",
8d86bd
-        [TIMER_FAILURE_RESOURCES]             = "resources",
8d86bd
-        [TIMER_FAILURE_START_LIMIT_HIT]       = "start-limit-hit",
8d86bd
-        [TIMER_FAILURE_UNIT_CONDITION_FAILED] = "unit-condition-failed",
8d86bd
+        [TIMER_SUCCESS] = "success",
8d86bd
+        [TIMER_FAILURE_RESOURCES] = "resources",
8d86bd
+        [TIMER_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
8d86bd
 };
8d86bd
 
8d86bd
 DEFINE_STRING_TABLE_LOOKUP(timer_result, TimerResult);
8d86bd
diff --git a/src/core/timer.h b/src/core/timer.h
8d86bd
index d23e19d622..833aadb0b8 100644
8d86bd
--- a/src/core/timer.h
8d86bd
+++ b/src/core/timer.h
8d86bd
@@ -32,7 +32,6 @@ typedef enum TimerResult {
8d86bd
         TIMER_SUCCESS,
8d86bd
         TIMER_FAILURE_RESOURCES,
8d86bd
         TIMER_FAILURE_START_LIMIT_HIT,
8d86bd
-        TIMER_FAILURE_UNIT_CONDITION_FAILED,
8d86bd
         _TIMER_RESULT_MAX,
8d86bd
         _TIMER_RESULT_INVALID = -1
8d86bd
 } TimerResult;
8d86bd
diff --git a/src/core/unit.c b/src/core/unit.c
8d86bd
index 0810bf5a58..dfe0c243ef 100644
8d86bd
--- a/src/core/unit.c
8d86bd
+++ b/src/core/unit.c
8d86bd
@@ -5661,16 +5661,6 @@ int unit_thaw_vtable_common(Unit *u) {
8d86bd
         return unit_cgroup_freezer_action(u, FREEZER_THAW);
8d86bd
 }
8d86bd
 
8d86bd
-bool unit_has_failed_condition_or_assert(Unit *u) {
8d86bd
-        if (dual_timestamp_is_set(&u->condition_timestamp) && !u->condition_result)
8d86bd
-                return true;
8d86bd
-
8d86bd
-        if (dual_timestamp_is_set(&u->assert_timestamp) && !u->assert_result)
8d86bd
-                return true;
8d86bd
-
8d86bd
-        return false;
8d86bd
-}
8d86bd
-
8d86bd
 static const char* const collect_mode_table[_COLLECT_MODE_MAX] = {
8d86bd
         [COLLECT_INACTIVE] = "inactive",
8d86bd
         [COLLECT_INACTIVE_OR_FAILED] = "inactive-or-failed",
8d86bd
diff --git a/src/core/unit.h b/src/core/unit.h
8d86bd
index a924bd2e83..b8b914711f 100644
8d86bd
--- a/src/core/unit.h
8d86bd
+++ b/src/core/unit.h
8d86bd
@@ -847,8 +847,6 @@ void unit_thawed(Unit *u);
8d86bd
 int unit_freeze_vtable_common(Unit *u);
8d86bd
 int unit_thaw_vtable_common(Unit *u);
8d86bd
 
8d86bd
-bool unit_has_failed_condition_or_assert(Unit *u);
8d86bd
-
8d86bd
 /* Macros which append UNIT= or USER_UNIT= to the message */
8d86bd
 
8d86bd
 #define log_unit_full(unit, level, error, ...)                          \