sd-bus: destroy AddMatch() reply slot in failure case too

If AddMatch() doesn't work, let's destroy the slot for it too as soon as
we received the failure for it.

This way the mere existance of the slot tells us whether the AddMatch()
method call is still pending or is complete.
This commit is contained in:
Lennart Poettering
2019-07-11 12:18:51 +02:00
parent f1617a3b61
commit 3cf8dd5359
+3 -2
View File
@@ -3246,8 +3246,6 @@ static int add_match_callback(
bus->current_slot = match_slot->match_callback.install_slot;
bus->current_handler = add_match_callback;
bus->current_userdata = userdata;
match_slot->match_callback.install_slot = sd_bus_slot_unref(match_slot->match_callback.install_slot);
} else {
if (failed) /* Generic failure handling: destroy the connection */
bus_enter_closing(sd_bus_message_get_bus(m));
@@ -3255,6 +3253,9 @@ static int add_match_callback(
r = 1;
}
/* We don't need the install method reply slot anymore, let's free it */
match_slot->match_callback.install_slot = sd_bus_slot_unref(match_slot->match_callback.install_slot);
if (failed && match_slot->floating)
bus_slot_disconnect(match_slot, true);