From b5eca3a2059f9399d1dc52cbcf9698674c4b1cf0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Jul 2014 17:29:09 +0200 Subject: bus: drop bus/message GC logic When a caller drops all references to a bus and its messages while the messages where still queue, this causes the bus to reference the messages, and the messages to reference the bus, without anybody else keeping a reference, which is something we so far considered a leak, and tried to fix with a GC logic that would recognize cases like this, and drop the reference. This GC logic has been broken sofar, and remained unfixed. This commit removes it altogther, replacing it with nothing. The rationale is that simply because all refs to the bus have been dropped its queued messages should *still* be written to the bus, even if the caller doesn't retain any reference to either bus nor message. This means it was actually wrong to attempt to clean up the bus in this case. The proper way how applications should handle this is by explicitly invoking sd_bus_close(), when they want busses to go away. This is probably want they want to do anyway to avoid getting spurious callbacks after they stopped using a bus. --- src/libsystemd/sd-bus/bus-message.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libsystemd/sd-bus/bus-message.c') diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index eaffa2d3a2..4768a1fa9e 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -801,9 +801,10 @@ _public_ sd_bus_message* sd_bus_message_unref(sd_bus_message *m) { assert(m->n_ref > 0); m->n_ref--; - if (m->n_ref <= 0) - message_free(m); + if (m->n_ref > 0) + return NULL; + message_free(m); return NULL; } -- cgit v1.2.3-54-g00ecf