summaryrefslogtreecommitdiff
path: root/src/core/job.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-04-20 12:28:31 +0200
committerMichal Schmidt <mschmidt@redhat.com>2012-04-20 17:12:29 +0200
commit97e6a11996855800f68dc41c13537784198c8b61 (patch)
treedf381f8225930b5adf0526d8a0a7987039b72c43 /src/core/job.c
parentd6a093d098054b6fe866441251ad9485c9e31584 (diff)
dbus-job: allow multiple bus clients
Merging of jobs can result in more than one client being interested in a job.
Diffstat (limited to 'src/core/job.c')
-rw-r--r--src/core/job.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 436f4a1b35..b21de44c14 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -33,6 +33,20 @@
#include "log.h"
#include "dbus-job.h"
+JobBusClient* job_bus_client_new(DBusConnection *connection, const char *name) {
+ JobBusClient *cl;
+ size_t name_len;
+
+ name_len = strlen(name);
+ cl = malloc0(sizeof(JobBusClient) + name_len + 1);
+ if (!cl)
+ return NULL;
+
+ cl->bus = connection;
+ memcpy(cl->name, name, name_len + 1);
+ return cl;
+}
+
Job* job_new(Unit *unit, JobType type) {
Job *j;
@@ -55,6 +69,8 @@ Job* job_new(Unit *unit, JobType type) {
}
void job_free(Job *j) {
+ JobBusClient *cl;
+
assert(j);
assert(!j->installed);
assert(!j->transaction_prev);
@@ -77,7 +93,10 @@ void job_free(Job *j) {
close_nointr_nofail(j->timer_watch.fd);
}
- free(j->bus_client);
+ while ((cl = j->bus_client_list)) {
+ LIST_REMOVE(JobBusClient, client, j->bus_client_list, cl);
+ free(cl);
+ }
free(j);
}