From 3cf8dd5359ad01eb5c291d2f12c33e84fb2c70b9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 Mar 2019 15:42:38 +0100 Subject: [PATCH] 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. --- src/libsystemd/sd-bus/sd-bus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index ac611d2..5b624d5 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -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); -- 2.7.4