]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: introduce MANAGER_IS_FINISHED() macro
authorLennart Poettering <lennart@poettering.net>
Mon, 20 Nov 2017 20:24:59 +0000 (21:24 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Nov 2017 10:01:34 +0000 (11:01 +0100)
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.

src/core/dbus-manager.c
src/core/manager.c
src/core/manager.h

index 5029f49a012a75ebd2c10382ae4424043198e6a6..e5b899fc0176bb8ca92d09e5abe541985c5cbf19 100644 (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);
index 97ca77c9fa43d8c9722628b10dece90e05e6c42b..0340b41ef9e5baf3dacdf376400f98de5de5f8cf 100644 (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)))
index 4271e0c6c0d14cc476633496ee7b3c6baef91ddf..779e09bc9735d18708ba3def16826594d0ba7b81 100644 (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);