sd-bus: split out handling of reply callbacks on close into its own function

When a bus connection is closed we dispatch all reply callbacks. Do so in a new
function if its own.

No behaviour changes.
This commit is contained in:
Lennart Poettering 2016-08-22 14:45:34 +02:00
parent 390bc2b149
commit 217fcc7eb3

View file

@ -2640,20 +2640,15 @@ null_message:
return r;
}
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
static int process_closing_reply_callback(sd_bus *bus, struct reply_callback *c) {
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct reply_callback *c;
sd_bus_slot *slot;
int r;
assert(bus);
assert(bus->state == BUS_CLOSING);
assert(c);
c = ordered_hashmap_first(bus->reply_callbacks);
if (c) {
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
sd_bus_slot *slot;
/* First, fail all outstanding method calls */
r = bus_message_new_synthetic_error(
bus,
c->cookie,
@ -2698,6 +2693,19 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
return bus_maybe_reply_error(m, r, &error_buffer);
}
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct reply_callback *c;
int r;
assert(bus);
assert(bus->state == BUS_CLOSING);
/* First, fail all outstanding method calls */
c = ordered_hashmap_first(bus->reply_callbacks);
if (c)
return process_closing_reply_callback(bus, c);
/* Then, synthesize a Disconnected message */
r = sd_bus_message_new_signal(
bus,