mirror of
https://github.com/systemd/systemd.git
synced 2025-02-09 13:57:42 +03:00
sd-bus: make bus_slot_disconnect() also unref the slot object
This makes bus_slot_disconnect() unref the slot object from bus when `unref == true` and it is floating, as the function removes the reference from the relevant bus object. This reverts 20d4ee2cbc21e0c4d2dd6c01d5a18a4cf0d98222, as it introduces #9604. Fixes #9604.
This commit is contained in:
parent
3bdfea0820
commit
2e7e8e34aa
@ -48,7 +48,7 @@ _public_ sd_bus_slot* sd_bus_slot_ref(sd_bus_slot *slot) {
|
||||
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);
|
||||
@ -79,10 +79,7 @@ void bus_slot_disconnect(sd_bus_slot *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);
|
||||
}
|
||||
|
||||
@ -186,6 +183,8 @@ void bus_slot_disconnect(sd_bus_slot *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) {
|
||||
@ -200,7 +199,7 @@ _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);
|
||||
|
@ -7,4 +7,4 @@
|
||||
|
||||
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);
|
||||
|
@ -178,8 +178,7 @@ static sd_bus* bus_free(sd_bus *b) {
|
||||
* 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)
|
||||
@ -2360,10 +2359,8 @@ static int process_timeout(sd_bus *bus) {
|
||||
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);
|
||||
|
||||
@ -2465,10 +2462,8 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) {
|
||||
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);
|
||||
|
||||
@ -2810,10 +2805,8 @@ static int process_closing_reply_callback(sd_bus *bus, struct reply_callback *c)
|
||||
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);
|
||||
|
||||
@ -3168,10 +3161,8 @@ static int add_match_callback(
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user