From: Lennart Poettering Date: Thu, 29 Nov 2018 17:48:52 +0000 (+0100) Subject: core: enqueue unit earlier when state changes X-Git-Tag: v240~127^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c4832ada41466b87203ad145af1af2b0040dcf5;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/unit.c b/src/core/unit.c index 9f715b164cb..7b8e0e37c79 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); }