return slot;
}
-void bus_slot_disconnect(sd_bus_slot *slot) {
+void bus_slot_disconnect(sd_bus_slot *slot, bool unref) {
sd_bus *bus;
assert(slot);
(void) bus_remove_match_internal(slot->bus, slot->match_callback.match_string);
if (slot->match_callback.install_slot) {
- if (slot->match_callback.install_slot->bus) {
- bus_slot_disconnect(slot->match_callback.install_slot);
- sd_bus_slot_unref(slot->match_callback.install_slot);
- }
+ bus_slot_disconnect(slot->match_callback.install_slot, true);
slot->match_callback.install_slot = sd_bus_slot_unref(slot->match_callback.install_slot);
}
if (!slot->floating)
sd_bus_unref(bus);
+ else if (unref)
+ sd_bus_slot_unref(slot);
}
_public_ sd_bus_slot* sd_bus_slot_unref(sd_bus_slot *slot) {
return NULL;
}
- bus_slot_disconnect(slot);
+ bus_slot_disconnect(slot, false);
if (slot->destroy_callback)
slot->destroy_callback(slot->userdata);
sd_bus_slot *bus_slot_allocate(sd_bus *bus, bool floating, BusSlotType type, size_t extra, void *userdata);
-void bus_slot_disconnect(sd_bus_slot *slot);
+void bus_slot_disconnect(sd_bus_slot *slot, bool unref);
* apps, but are dead. */
assert(s->floating);
- bus_slot_disconnect(s);
- sd_bus_slot_unref(s);
+ bus_slot_disconnect(s, true);
}
if (b->default_bus_ptr)
bus->current_slot = NULL;
bus->current_message = NULL;
- if (slot->floating) {
- bus_slot_disconnect(slot);
- sd_bus_slot_unref(slot);
- }
+ if (slot->floating)
+ bus_slot_disconnect(slot, true);
sd_bus_slot_unref(slot);
bus->current_handler = NULL;
bus->current_slot = NULL;
- if (slot->floating) {
- bus_slot_disconnect(slot);
- sd_bus_slot_unref(slot);
- }
+ if (slot->floating)
+ bus_slot_disconnect(slot, true);
sd_bus_slot_unref(slot);
bus->current_slot = NULL;
bus->current_message = NULL;
- if (slot->floating) {
- bus_slot_disconnect(slot);
- sd_bus_slot_unref(slot);
- }
+ if (slot->floating)
+ bus_slot_disconnect(slot, true);
sd_bus_slot_unref(slot);
r = 1;
}
- if (failed && match_slot->floating) {
- bus_slot_disconnect(match_slot);
- sd_bus_slot_unref(match_slot);
- }
+ if (failed && match_slot->floating)
+ bus_slot_disconnect(match_slot, true);
sd_bus_slot_unref(match_slot);