manager: add MANAGER_IS_RUNNING() for checking whether the manager is running
authorLennart Poettering <lennart@poettering.net>
Tue, 23 Jan 2018 15:43:56 +0000 (16:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Jan 2018 15:43:56 +0000 (16:43 +0100)
This macro is useful as the check is not obvious, and we better abstract
this away.

src/core/manager.c
src/core/manager.h

index 0a326dc..3d18a0e 100644 (file)
@@ -3234,10 +3234,8 @@ void manager_check_finished(Manager *m) {
         if (MANAGER_IS_RELOADING(m))
                 return;
 
-        /* Verify that we are actually running currently. Initially
-         * the exit code is set to invalid, and during operation it is
-         * then set to MANAGER_OK */
-        if (m->exit_code != MANAGER_OK)
+        /* Verify that we have entered the event loop already, and not left it again. */
+        if (!MANAGER_IS_RUNNING(m))
                 return;
 
         manager_check_basic_target(m);
index b01edea..216ecea 100644 (file)
@@ -359,6 +359,9 @@ struct Manager {
 
 #define MANAGER_IS_FINISHED(m) (dual_timestamp_is_set((m)->timestamps + MANAGER_TIMESTAMP_FINISH))
 
+/* The exit code is set to OK as soon as we enter the main loop, and set otherwise as soon as we are done with it */
+#define MANAGER_IS_RUNNING(m) ((m)->exit_code == MANAGER_OK)
+
 int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **m);
 Manager* manager_free(Manager *m);