From 3c4832ada41466b87203ad145af1af2b0040dcf5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 29 Nov 2018 18:48:52 +0100 Subject: [PATCH] core: enqueue unit earlier when state changes Previously, we'd enqueue a unit to the dbus queue whenever the state changed, after we processed the state change fully. This commit to the beginning of the state change. This has the benefit that when the state change causes a job to complete the unit is already in the dbus queue, and thus we get the guarantee that any unit change can be sent out to clients before the job change. --- src/core/unit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/unit.c b/src/core/unit.c index 9f715b164c..7b8e0e37c7 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2341,6 +2341,10 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag m = u->manager; + /* Let's enqueue the change signal early. In case this unit has a job associated we want that this unit is in + * the bus queue, so that any job change signal queued will force out the unit change signal first. */ + unit_add_to_dbus_queue(u); + /* Update timestamps for state changes */ if (!MANAGER_IS_RELOADING(m)) { dual_timestamp_get(&u->state_change_timestamp); @@ -2499,7 +2503,6 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag } } - unit_add_to_dbus_queue(u); unit_add_to_gc_queue(u); }