From: Lennart Poettering Date: Fri, 29 Mar 2019 14:42:38 +0000 (+0100) Subject: sd-bus: destroy AddMatch() reply slot in failure case too X-Git-Tag: v243-rc1~153^2~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3cf8dd5359ad01eb5c291d2f12c33e84fb2c70b9;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index ac611d29759..5b624d51ed0 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);