summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-05 00:38:41 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-05 00:38:41 +0100
commitc1e1601e8c6cace85b19a0eebe50076e5d119688 (patch)
tree26fe0f48cbcdbfeb21abfef75c1de3ee37e9598e /job.c
parentab8ea24411df95861c53aeee1dd91e765331f717 (diff)
dbus: send out signals when units/jobs come, go and change
Diffstat (limited to 'job.c')
-rw-r--r--job.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/job.c b/job.c
index 4784d9c05d..be42eaff62 100644
--- a/job.c
+++ b/job.c
@@ -55,6 +55,8 @@ void job_free(Job *j) {
/* Detach from next 'bigger' objects */
if (j->installed) {
+ bus_job_send_removed_signal(j);
+
if (j->unit->meta.job == j)
j->unit->meta.job = NULL;
@@ -65,6 +67,12 @@ void job_free(Job *j) {
/* Detach from next 'smaller' objects */
manager_transaction_unlink_job(j->manager, j);
+ if (j->in_run_queue)
+ LIST_REMOVE(Job, run_queue, j->manager->run_queue, j);
+
+ if (j->in_dbus_queue)
+ LIST_REMOVE(Job, dbus_queue, j->manager->dbus_job_queue, j);
+
free(j);
}
@@ -326,6 +334,7 @@ int job_run_and_invalidate(Job *j) {
return -EAGAIN;
j->state = JOB_RUNNING;
+ job_add_to_dbus_queue(j);
switch (j->type) {
@@ -408,6 +417,7 @@ int job_finish_and_invalidate(Job *j, bool success) {
assert(j->installed);
log_debug("Job %s/%s finished, success=%s", unit_id(j->unit), job_type_to_string(j->type), yes_no(success));
+ job_add_to_dbus_queue(j);
/* Patch restart jobs so that they become normal start jobs */
if (success && (j->type == JOB_RESTART || j->type == JOB_TRY_RESTART)) {
@@ -419,7 +429,7 @@ int job_finish_and_invalidate(Job *j, bool success) {
j->state = JOB_RUNNING;
j->type = JOB_START;
- job_schedule_run(j);
+ job_add_to_run_queue(j);
return 0;
}
@@ -463,15 +473,15 @@ int job_finish_and_invalidate(Job *j, bool success) {
/* Try to start the next jobs that can be started */
SET_FOREACH(other, u->meta.dependencies[UNIT_AFTER], i)
if (other->meta.job)
- job_schedule_run(other->meta.job);
+ job_add_to_run_queue(other->meta.job);
SET_FOREACH(other, u->meta.dependencies[UNIT_BEFORE], i)
if (other->meta.job)
- job_schedule_run(other->meta.job);
+ job_add_to_run_queue(other->meta.job);
return 0;
}
-void job_schedule_run(Job *j) {
+void job_add_to_run_queue(Job *j) {
assert(j);
assert(j->installed);
@@ -482,6 +492,17 @@ void job_schedule_run(Job *j) {
j->in_run_queue = true;
}
+void job_add_to_dbus_queue(Job *j) {
+ assert(j);
+ assert(j->installed);
+
+ if (j->in_dbus_queue)
+ return;
+
+ LIST_PREPEND(Job, dbus_queue, j->manager->dbus_job_queue, j);
+ j->in_dbus_queue = true;
+}
+
char *job_dbus_path(Job *j) {
char *p;