summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-bus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-30 01:02:51 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-30 01:02:51 +0100
commita43b9ca3049d0f27cdb3bc8dad703e688cba31b3 (patch)
tree3a459cde6758bdb6f2cad5b280251930eee4f7d4 /src/libsystemd-bus/sd-bus.c
parent7adc46fcce257fcf4c83faa18b8c78f2a577e4f1 (diff)
bus: synthesize local error reply when we cannot deliver a message to kdbus because the destination is unavailable
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r--src/libsystemd-bus/sd-bus.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 0eb61c4bd3..05c5d8d1bc 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1274,9 +1274,9 @@ static int bus_write_message(sd_bus *bus, sd_bus_message *message, size_t *idx)
assert(message);
if (bus->is_kernel)
- r = bus_kernel_write_message(bus, message);
+ return bus_kernel_write_message(bus, message);
else
- r = bus_socket_write_message(bus, message, idx);
+ return bus_socket_write_message(bus, message, idx);
return r;
}
@@ -1627,20 +1627,17 @@ _public_ int sd_bus_call(
if (r < 0)
return r;
+ i = bus->rqueue_size;
+
r = sd_bus_send(bus, m, &serial);
if (r < 0)
return r;
timeout = calc_elapse(usec);
- i = bus->rqueue_size;
for (;;) {
usec_t left;
- r = bus_read_message(bus);
- if (r < 0)
- return r;
-
while (i < bus->rqueue_size) {
sd_bus_message *incoming = NULL;
@@ -1660,24 +1657,13 @@ _public_ int sd_bus_call(
sd_bus_message_unref(incoming);
return 1;
- }
-
- if (incoming->header->type == SD_BUS_MESSAGE_METHOD_ERROR) {
- int k;
-
+ } else if (incoming->header->type == SD_BUS_MESSAGE_METHOD_ERROR)
r = sd_bus_error_copy(error, &incoming->error);
- if (r < 0) {
- sd_bus_message_unref(incoming);
- return r;
- }
-
- k = sd_bus_error_get_errno(&incoming->error);
- sd_bus_message_unref(incoming);
- return -k;
- }
+ else
+ r = -EIO;
sd_bus_message_unref(incoming);
- return -EIO;
+ return r;
} else if (incoming->header->serial == serial &&
bus->unique_name &&
@@ -1700,6 +1686,9 @@ _public_ int sd_bus_call(
i++;
}
+ r = bus_read_message(bus);
+ if (r < 0)
+ return r;
if (r > 0)
continue;