1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

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.
This commit is contained in:
Lennart Poettering 2017-11-20 21:24:59 +01:00
parent 713f6f901d
commit 49d5666cc5
3 changed files with 5 additions and 3 deletions

View File

@ -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);

View File

@ -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)))

View File

@ -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);