From 4259d202159bc22ea0a01cdd3475ba5500b79301 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 23 Jan 2018 16:43:56 +0100 Subject: [PATCH] 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. --- src/core/manager.c | 6 ++---- src/core/manager.h | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index 0a326dc..3d18a0e 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 b01edea..216ecea 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); -- 2.7.4