From: Lennart Poettering Date: Mon, 20 Nov 2017 20:24:59 +0000 (+0100) Subject: manager: introduce MANAGER_IS_FINISHED() macro X-Git-Tag: v236~148^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49d5666cc500d0efa2fd800403ac735707f976ed;p=thirdparty%2Fsystemd.git manager: introduce MANAGER_IS_FINISHED() macro Let's make our finished checks a bit more readable. Checking the timestamp is not entirely obvious, hence let's abstract that a bit by adding a macro that shows what we are doing here, not how we doing it. This is particularly useful if we want to change the definition of "finished" later on, in particular, when we try to fix #7023. --- diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 5029f49a012..e5b899fc017 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -323,7 +323,7 @@ static int property_get_progress( assert(reply); assert(m); - if (dual_timestamp_is_set(m->timestamps + MANAGER_TIMESTAMP_FINISH)) + if (MANAGER_IS_FINISHED(m)) d = 1.0; else d = 1.0 - ((double) hashmap_size(m->jobs) / (double) m->n_installed_jobs); diff --git a/src/core/manager.c b/src/core/manager.c index 97ca77c9fa4..0340b41ef9e 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3175,7 +3175,7 @@ void manager_check_finished(Manager *m) { /* This is no longer the first boot */ manager_set_first_boot(m, false); - if (dual_timestamp_is_set(m->timestamps + MANAGER_TIMESTAMP_FINISH)) + if (MANAGER_IS_FINISHED(m)) return; dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_FINISH); @@ -3533,7 +3533,7 @@ ManagerState manager_state(Manager *m) { assert(m); /* Did we ever finish booting? If not then we are still starting up */ - if (!dual_timestamp_is_set(m->timestamps + MANAGER_TIMESTAMP_FINISH)) { + if (!MANAGER_IS_FINISHED(m)) { u = manager_get_unit(m, SPECIAL_BASIC_TARGET); if (!u || !UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u))) diff --git a/src/core/manager.h b/src/core/manager.h index 4271e0c6c0d..779e09bc973 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -352,6 +352,8 @@ struct Manager { #define MANAGER_IS_RELOADING(m) ((m)->n_reloading > 0) +#define MANAGER_IS_FINISHED(m) (dual_timestamp_is_set((m)->timestamps + MANAGER_TIMESTAMP_FINISH)) + int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **m); Manager* manager_free(Manager *m);