From: Lennart Poettering Date: Tue, 23 Jan 2018 15:43:56 +0000 (+0100) Subject: manager: add MANAGER_IS_RUNNING() for checking whether the manager is running X-Git-Tag: v237~40^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4259d202159bc22ea0a01cdd3475ba5500b79301;p=thirdparty%2Fsystemd.git manager: add MANAGER_IS_RUNNING() for checking whether the manager is running This macro is useful as the check is not obvious, and we better abstract this away. --- diff --git a/src/core/manager.c b/src/core/manager.c index 0a326dc58a3..3d18a0eed68 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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); diff --git a/src/core/manager.h b/src/core/manager.h index b01edea1b57..216ecea6fd8 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -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);