]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: rerun GC logic for a unit that loses a reference
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Apr 2016 09:18:53 +0000 (11:18 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 Apr 2016 14:27:49 +0000 (16:27 +0200)
Let's make sure when we drop a reference to a unit, that we run the GC queue on
it again.

This (together with the previous commit) should deal with the GC issues pointed
out in:

https://github.com/systemd/systemd/pull/2993#issuecomment-215331189

src/core/unit.c

index 6c0684225a3fe229541014d7c7e4cbe07af9e245..81cd7ee2b8105467d1fe3b7b12681b1eea9ab70e 100644 (file)
@@ -3222,6 +3222,10 @@ void unit_ref_unset(UnitRef *ref) {
         if (!ref->unit)
                 return;
 
+        /* We are about to drop a reference to the unit, make sure the garbage collection has a look at it as it might
+         * be unreferenced now. */
+        unit_add_to_gc_queue(ref->unit);
+
         LIST_REMOVE(refs, ref->unit->refs, ref);
         ref->unit = NULL;
 }