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.
This commit is contained in:
Lennart Poettering
2018-12-01 12:53:26 +01:00
parent 17407bc28d
commit 13142276c1
3 changed files with 19 additions and 0 deletions
+15
View File
@@ -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;
+1
View File
@@ -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);
+3
View File
@@ -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);
}