mirror of
https://github.com/systemd/systemd.git
synced 2025-09-02 17:49:53 +03:00
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:
@ -2640,20 +2640,15 @@ null_message:
|
|||||||
return r;
|
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;
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||||
struct reply_callback *c;
|
sd_bus_slot *slot;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(bus);
|
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(
|
r = bus_message_new_synthetic_error(
|
||||||
bus,
|
bus,
|
||||||
c->cookie,
|
c->cookie,
|
||||||
@ -2696,7 +2691,20 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
|
|||||||
sd_bus_slot_unref(slot);
|
sd_bus_slot_unref(slot);
|
||||||
|
|
||||||
return bus_maybe_reply_error(m, r, &error_buffer);
|
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 */
|
/* Then, synthesize a Disconnected message */
|
||||||
r = sd_bus_message_new_signal(
|
r = sd_bus_message_new_signal(
|
||||||
|
Reference in New Issue
Block a user