summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-05 20:51:49 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-05 20:51:49 +0100
commitaffff0b6f2b267254fee981a010e06cd55d9756a (patch)
treea31947327ece1e58a7e9e6eef868fa30f5e54c64
parent4e724d9c5ab76c3f8327945317463ef706011082 (diff)
bus: add sd_bus_get_current() bus call to determine message that is currently being dispatched
-rw-r--r--src/libsystemd-bus/bus-internal.h2
-rw-r--r--src/libsystemd-bus/sd-bus.c23
-rw-r--r--src/systemd/sd-bus.h2
3 files changed, 21 insertions, 6 deletions
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index 913f281316..2112a29687 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -247,6 +247,8 @@ struct sd_bus {
sd_event_source *time_event_source;
sd_event_source *quit_event_source;
sd_event *event;
+
+ sd_bus_message *current;
};
#define BUS_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC))
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index a9f238ef22..e68f127b70 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1931,6 +1931,7 @@ static int process_message(sd_bus *bus, sd_bus_message *m) {
assert(bus);
assert(m);
+ bus->current = m;
bus->iteration_counter++;
log_debug("Got message sender=%s object=%s interface=%s member=%s",
@@ -1941,25 +1942,29 @@ static int process_message(sd_bus *bus, sd_bus_message *m) {
r = process_hello(bus, m);
if (r != 0)
- return r;
+ goto finish;
r = process_reply(bus, m);
if (r != 0)
- return r;
+ goto finish;
r = process_filter(bus, m);
if (r != 0)
- return r;
+ goto finish;
r = process_match(bus, m);
if (r != 0)
- return r;
+ goto finish;
r = process_builtin(bus, m);
if (r != 0)
- return r;
+ goto finish;
+
+ r = bus_process_object(bus, m);
- return bus_process_object(bus, m);
+finish:
+ bus->current = NULL;
+ return r;
}
static int process_running(sd_bus *bus, sd_bus_message **ret) {
@@ -2422,3 +2427,9 @@ int sd_bus_detach_event(sd_bus *bus) {
return 0;
}
+
+sd_bus_message* sd_bus_get_current(sd_bus *bus) {
+ assert_return(bus, NULL);
+
+ return bus->current;
+}
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 6b43a23d00..48edc59188 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -101,6 +101,8 @@ int sd_bus_process(sd_bus *bus, sd_bus_message **r);
int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
int sd_bus_flush(sd_bus *bus);
+sd_bus_message* sd_bus_get_current(sd_bus *bus);
+
int sd_bus_attach_event(sd_bus *bus, sd_event *e, int priority);
int sd_bus_detach_event(sd_bus *bus);