]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exit-status: introduce common exit_status_set_test() call for testing exit status...
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Apr 2015 16:24:20 +0000 (18:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 28 Apr 2015 19:34:23 +0000 (21:34 +0200)
src/core/service.c
src/shared/exit-status.c
src/shared/exit-status.h

index 9104347f27adec09b7040b9ce694a6e6b6f13b9e..d004728671e79cc355f315a3adad760726c809f2 100644 (file)
@@ -1290,10 +1290,8 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
              (s->restart == SERVICE_RESTART_ON_ABNORMAL && !IN_SET(s->result, SERVICE_SUCCESS, SERVICE_FAILURE_EXIT_CODE)) ||
              (s->restart == SERVICE_RESTART_ON_WATCHDOG && s->result == SERVICE_FAILURE_WATCHDOG) ||
              (s->restart == SERVICE_RESTART_ON_ABORT && IN_SET(s->result, SERVICE_FAILURE_SIGNAL, SERVICE_FAILURE_CORE_DUMP)) ||
-             (s->main_exec_status.code == CLD_EXITED && set_contains(s->restart_force_status.status, INT_TO_PTR(s->main_exec_status.status))) ||
-             (IN_SET(s->main_exec_status.code, CLD_KILLED, CLD_DUMPED) && set_contains(s->restart_force_status.signal, INT_TO_PTR(s->main_exec_status.status)))) &&
-            (s->main_exec_status.code != CLD_EXITED || !set_contains(s->restart_prevent_status.status, INT_TO_PTR(s->main_exec_status.status))) &&
-            (!IN_SET(s->main_exec_status.code, CLD_KILLED, CLD_DUMPED) || !set_contains(s->restart_prevent_status.signal, INT_TO_PTR(s->main_exec_status.status)))) {
+             exit_status_set_test(&s->restart_force_status,  s->main_exec_status.code, s->main_exec_status.status)) &&
+            !exit_status_set_test(&s->restart_prevent_status, s->main_exec_status.code, s->main_exec_status.status)) {
 
                 r = service_arm_timer(s, s->restart_usec);
                 if (r < 0)
index 9e14eb8bf5fe231d58a24f4507a1e574aa156526..c09efdd2cb79c1643aed2c8042e3f90f361d8f07 100644 (file)
@@ -225,3 +225,17 @@ bool exit_status_set_is_empty(ExitStatusSet *x) {
 
         return set_isempty(x->status) && set_isempty(x->signal);
 }
+
+bool exit_status_set_test(ExitStatusSet *x, int code, int status) {
+
+        if (exit_status_set_is_empty(x))
+                return false;
+
+        if (code == CLD_EXITED && set_contains(x->status, INT_TO_PTR(status)))
+                return true;
+
+        if (IN_SET(code, CLD_KILLED, CLD_DUMPED) && set_contains(x->signal, INT_TO_PTR(status)))
+                return true;
+
+        return false;
+}
index 1d774f25dca173c8a66b847988bbe388cfef7918..7259cd1d18ae612b2679b64d89914a6427babdbf 100644 (file)
@@ -100,3 +100,4 @@ bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status);
 
 void exit_status_set_free(ExitStatusSet *x);
 bool exit_status_set_is_empty(ExitStatusSet *x);
+bool exit_status_set_test(ExitStatusSet *x, int code, int status);