]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: get rid of unused Service.will_auto_restart logic
authorMike Yuan <me@yhndnzj.com>
Mon, 22 May 2023 00:30:30 +0000 (08:30 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 24 May 2023 13:37:02 +0000 (21:37 +0800)
The announced new behavior for OnFailure= never worked properly,
and we've fixed the document instead in #27675.
Therefore, let's get rid of the unused logic completely. More at #27594.

The to-be-added RestartMode= option should cover the use case hopefully.

Closes #27594

src/core/service.c
src/core/service.h
src/core/unit.c
src/core/unit.h

index 41e61987712f2c06ee0dbd390890de686870eb6e..ad8ff75b1421650a1c713c2daddaa5a20e371178 100644 (file)
@@ -1946,8 +1946,6 @@ static bool service_will_restart(Unit *u) {
 
         assert(s);
 
-        if (s->will_auto_restart)
-                return true;
         if (IN_SET(s->state, SERVICE_DEAD_BEFORE_AUTO_RESTART, SERVICE_FAILED_BEFORE_AUTO_RESTART, SERVICE_AUTO_RESTART))
                 return true;
 
@@ -1993,19 +1991,14 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
                 log_unit_debug(UNIT(s), "Service restart not allowed.");
         else {
                 const char *reason;
-                bool shall_restart;
 
-                shall_restart = service_shall_restart(s, &reason);
+                allow_restart = service_shall_restart(s, &reason);
                 log_unit_debug(UNIT(s), "Service will %srestart (%s)",
-                                        shall_restart ? "" : "not ",
+                                        allow_restart ? "" : "not ",
                                         reason);
-                if (shall_restart)
-                        s->will_auto_restart = true;
         }
 
-        if (s->will_auto_restart) {
-                s->will_auto_restart = false;
-
+        if (allow_restart) {
                 /* We make two state changes here: one that maps to the high-level UNIT_INACTIVE/UNIT_FAILED
                  * state (i.e. a state indicating deactivation), and then one that that maps to the
                  * high-level UNIT_STARTING state (i.e. a state indicating activation). We do this so that
index 55c4127deed84b7dcc76b9d8e91065cabdc709fd..0e578c9280b841a9effdd971fe53cd1e467cda21 100644 (file)
@@ -181,8 +181,6 @@ struct Service {
         bool main_pid_alien:1;
         bool bus_name_good:1;
         bool forbid_restart:1;
-        /* Keep restart intention between UNIT_FAILED and UNIT_ACTIVATING */
-        bool will_auto_restart:1;
         bool start_timeout_defined:1;
         bool exec_fd_hot:1;
 
index 3393138bac1fd5b3cecca92c6e677169b2a9968c..49d289c04d4e79692688e42cacb69258306deb6a 100644 (file)
@@ -2777,9 +2777,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
 
                 if (ns != os && ns == UNIT_FAILED) {
                         log_unit_debug(u, "Unit entered failed state.");
-
-                        if (!(flags & UNIT_NOTIFY_WILL_AUTO_RESTART))
-                                unit_start_on_failure(u, "OnFailure=", UNIT_ATOM_ON_FAILURE, u->on_failure_job_mode);
+                        unit_start_on_failure(u, "OnFailure=", UNIT_ATOM_ON_FAILURE, u->on_failure_job_mode);
                 }
 
                 if (UNIT_IS_ACTIVE_OR_RELOADING(ns) && !UNIT_IS_ACTIVE_OR_RELOADING(os)) {
@@ -2796,8 +2794,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
                         unit_log_resources(u);
                 }
 
-                if (ns == UNIT_INACTIVE && !IN_SET(os, UNIT_FAILED, UNIT_INACTIVE, UNIT_MAINTENANCE) &&
-                    !(flags & UNIT_NOTIFY_WILL_AUTO_RESTART))
+                if (ns == UNIT_INACTIVE && !IN_SET(os, UNIT_FAILED, UNIT_INACTIVE, UNIT_MAINTENANCE))
                         unit_start_on_failure(u, "OnSuccess=", UNIT_ATOM_ON_SUCCESS, u->on_success_job_mode);
         }
 
index 7e85150643ec4c4418abcfa9870139d9d0295be2..3cab35ea4f829ae6c12700c516c68d2b28cc71c0 100644 (file)
@@ -904,7 +904,6 @@ void unit_notify_cgroup_oom(Unit *u, bool managed_oom);
 
 typedef enum UnitNotifyFlags {
         UNIT_NOTIFY_RELOAD_FAILURE    = 1 << 0,
-        UNIT_NOTIFY_WILL_AUTO_RESTART = 1 << 1,
 } UnitNotifyFlags;
 
 void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlags flags);