From 97e6a11996855800f68dc41c13537784198c8b61 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Fri, 20 Apr 2012 12:28:31 +0200 Subject: dbus-job: allow multiple bus clients Merging of jobs can result in more than one client being interested in a job. --- src/core/job.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/core/job.c') 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); } -- cgit v1.2.3-54-g00ecf