ryantimwilson / rpms / systemd

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