From: Lennart Poettering Date: Thu, 29 Nov 2018 17:48:20 +0000 (+0100) Subject: core: before returning new job path to clients, force out JobNew signals X-Git-Tag: v240~127^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13142276c1bbb6562aedeb5e828a00c9b6b45d96;p=thirdparty%2Fsystemd.git core: before returning new job path to clients, force out JobNew signals When a client requests a new job, let's make sure we for out the JobNew signals for it, before we return successfully from the method call. After all we shouldn't return a path that is not announced yet, as announcement of jobs should be considered part of the job setup. --- diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index acb9f55a5ec..d11e58b51dd 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -189,6 +189,21 @@ void bus_job_send_change_signal(Job *j) { j->sent_dbus_new_signal = true; } +void bus_job_send_pending_change_signal(Job *j, bool including_new) { + assert(j); + + if (!j->in_dbus_queue) + return; + + if (!j->sent_dbus_new_signal && !including_new) + return; + + if (MANAGER_IS_RELOADING(j->unit->manager)) + return; + + bus_job_send_change_signal(j); +} + static int send_removed_signal(sd_bus *bus, void *userdata) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_free_ char *p = NULL; diff --git a/src/core/dbus-job.h b/src/core/dbus-job.h index 3cc60f22ee0..c9f6fc71871 100644 --- a/src/core/dbus-job.h +++ b/src/core/dbus-job.h @@ -12,6 +12,7 @@ int bus_job_method_cancel(sd_bus_message *message, void *job, sd_bus_error *erro int bus_job_method_get_waiting_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error); void bus_job_send_change_signal(Job *j); +void bus_job_send_pending_change_signal(Job *j, bool including_new); void bus_job_send_removed_signal(Job *j); int bus_job_coldplug_bus_track(Job *j); diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 4cf7364c50e..5665bf97a84 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -1321,6 +1321,9 @@ int bus_unit_queue_job( if (!path) return -ENOMEM; + /* Before we send the method reply, force out the announcement JobNew for this job */ + bus_job_send_pending_change_signal(j, true); + return sd_bus_reply_method_return(message, "o", path); }