]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: destroy AddMatch() reply slot in failure case too
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Mar 2019 14:42:38 +0000 (15:42 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Jul 2019 10:18:51 +0000 (12:18 +0200)
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

index ac611d29759d5e8046baada5c3c36220fe904764..5b624d51ed03bb185b1bfa6a67a94cac77ed7fec 100644 (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);