chiark / gitweb /
exit-status: rename ExitStatusSet's "code" field to "status"
authorLennart Poettering <lennart@poettering.net>
Thu, 3 Jul 2014 13:36:50 +0000 (15:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Jul 2014 13:37:46 +0000 (15:37 +0200)
We should follow the naming scheme waitid() uses, not come up with our
own reversed one...

src/core/load-fragment.c
src/core/service.c
src/shared/exit-status.c
src/shared/exit-status.h

index 0f5e71b8d3f5b8c1ed66116553938c0f1209f50f..b6894d22ae9f7e60675ad1094ce02c17b3abd609 100644 (file)
@@ -2935,13 +2935,9 @@ int config_parse_set_status(
         assert(rvalue);
         assert(data);
 
+        /* Empty assignment resets the list */
         if (isempty(rvalue)) {
-                /* Empty assignment resets the list */
-
-                set_free(status_set->signal);
-                set_free(status_set->code);
-
-                status_set->signal = status_set->code = NULL;
+                exit_status_set_free(status_set);
                 return 0;
         }
 
@@ -2958,7 +2954,7 @@ int config_parse_set_status(
                         val = signal_from_string_try_harder(temp);
 
                         if (val > 0) {
-                                r = set_ensure_allocated(&status_set->signal, trivial_hash_func, trivial_compare_func);
+                                r = set_ensure_allocated(&status_set->signal, NULL, NULL);
                                 if (r < 0)
                                         return log_oom();
 
@@ -2975,11 +2971,11 @@ int config_parse_set_status(
                         if (val < 0 || val > 255)
                                 log_syntax(unit, LOG_ERR, filename, line, ERANGE, "Value %d is outside range 0-255, ignoring", val);
                         else {
-                                r = set_ensure_allocated(&status_set->code, trivial_hash_func, trivial_compare_func);
+                                r = set_ensure_allocated(&status_set->status, NULL, NULL);
                                 if (r < 0)
                                         return log_oom();
 
-                                r = set_put(status_set->code, INT_TO_PTR(val));
+                                r = set_put(status_set->status, INT_TO_PTR(val));
                                 if (r < 0) {
                                         log_syntax(unit, LOG_ERR, filename, line, -r, "Unable to store: %s", w);
                                         return r;
index e22189959143f94de0d48dfd8c4d9d33a4f27978..be88670bd835fa2b6f5843b4f0146a0557f787bc 100644 (file)
@@ -335,7 +335,7 @@ static int service_verify(Service *s) {
                 return -EINVAL;
         }
 
-        if (s->type == SERVICE_ONESHOT && !(set_isempty(s->restart_force_status.signal) && set_isempty(s->restart_force_status.code))) {
+        if (s->type == SERVICE_ONESHOT && !(set_isempty(s->restart_force_status.signal) && set_isempty(s->restart_force_status.status))) {
                 log_error_unit(UNIT(s)->id, "%s has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
                 return -EINVAL;
         }
@@ -1071,9 +1071,9 @@ 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.code, INT_TO_PTR(s->main_exec_status.status))) ||
+             (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.code, 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)))) {
 
                 r = service_arm_timer(s, s->restart_usec);
index 38d71e182dab97760f141e351dc82638edbb02ce..942ac86128be814a384be4801d1dc3c77df938b9 100644 (file)
@@ -183,7 +183,7 @@ bool is_clean_exit(int code, int status, ExitStatusSet *success_status) {
         if (code == CLD_EXITED)
                 return status == 0 ||
                        (success_status &&
-                       set_contains(success_status->code, INT_TO_PTR(status)));
+                       set_contains(success_status->status, INT_TO_PTR(status)));
 
         /* If a daemon does not implement handlers for some of the
          * signals that's not considered an unclean shutdown */
@@ -212,7 +212,7 @@ bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status) {
 void exit_status_set_free(ExitStatusSet *x) {
         assert(x);
 
-        set_free(x->code);
+        set_free(x->status);
         set_free(x->signal);
-        x->code = x->signal = NULL;
+        x->status = x->signal = NULL;
 }
index 93abf7f10ee3fb3a858e55101df8244d5b48f1b2..744f2d53762d126b27f94495ea6760845f1d6ac7 100644 (file)
@@ -87,7 +87,7 @@ typedef enum ExitStatusLevel {
 } ExitStatusLevel;
 
 typedef struct ExitStatusSet {
-        Set *code;
+        Set *status;
         Set *signal;
 } ExitStatusSet;