summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-socket.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-29 21:29:16 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-29 22:03:55 +0100
commit7d22c717329c6317f97ccd0f68040a3a2b98e760 (patch)
tree72a5818287e9bd9d5de0720b10f636c6a9d6ca2c /src/libsystemd-bus/bus-socket.c
parent3519d4c895b45adc6e0791e1a344574f78b2d1be (diff)
bus: add the ability for backends to queue to input messages at the same time
We need this so that one incoming kernel message can result in two high-level bus messages, for the case where we synthesize NameAcquired and NameOwnerChanged in the same instance.
Diffstat (limited to 'src/libsystemd-bus/bus-socket.c')
-rw-r--r--src/libsystemd-bus/bus-socket.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index 6845f9d1bb..355f31c562 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -891,13 +891,12 @@ static int bus_socket_read_message_need(sd_bus *bus, size_t *need) {
return 0;
}
-static int bus_socket_make_message(sd_bus *bus, size_t size, sd_bus_message **m) {
+static int bus_socket_make_message(sd_bus *bus, size_t size) {
sd_bus_message *t;
void *b;
int r;
assert(bus);
- assert(m);
assert(bus->rbuffer_size >= size);
assert(bus->state == BUS_RUNNING || bus->state == BUS_HELLO);
@@ -926,11 +925,16 @@ static int bus_socket_make_message(sd_bus *bus, size_t size, sd_bus_message **m)
bus->fds = NULL;
bus->n_fds = 0;
- *m = t;
+ r = bus_rqueue_push(bus, t);
+ if (r < 0) {
+ sd_bus_message_unref(t);
+ return r;
+ }
+
return 1;
}
-int bus_socket_read_message(sd_bus *bus, sd_bus_message **m) {
+int bus_socket_read_message(sd_bus *bus) {
struct msghdr mh;
struct iovec iov;
ssize_t k;
@@ -947,15 +951,18 @@ int bus_socket_read_message(sd_bus *bus, sd_bus_message **m) {
bool handle_cmsg = false;
assert(bus);
- assert(m);
assert(bus->state == BUS_RUNNING || bus->state == BUS_HELLO);
+ r = bus_rqueue_make_room(bus, 1);
+ if (r < 0)
+ return r;
+
r = bus_socket_read_message_need(bus, &need);
if (r < 0)
return r;
if (bus->rbuffer_size >= need)
- return bus_socket_make_message(bus, need, m);
+ return bus_socket_make_message(bus, need);
b = realloc(bus->rbuffer, need);
if (!b)
@@ -1045,7 +1052,7 @@ int bus_socket_read_message(sd_bus *bus, sd_bus_message **m) {
return r;
if (bus->rbuffer_size >= need)
- return bus_socket_make_message(bus, need, m);
+ return bus_socket_make_message(bus, need);
return 1;
}