ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
923a60
From 0ace07115f14a57c81afbc9a7e947778a743870e Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Fri, 29 Apr 2016 11:18:53 +0200
923a60
Subject: [PATCH] core: rerun GC logic for a unit that loses a reference
923a60
923a60
Let's make sure when we drop a reference to a unit, that we run the GC queue on
923a60
it again.
923a60
923a60
This (together with the previous commit) should deal with the GC issues pointed
923a60
out in:
923a60
923a60
https://github.com/systemd/systemd/pull/2993#issuecomment-215331189
923a60
(cherry picked from commit b75102e5bf4cf249052d42be955d403e3e03b47c)
923a60
923a60
Related: #1718953
923a60
---
923a60
 src/core/unit.c | 4 ++++
923a60
 1 file changed, 4 insertions(+)
923a60
923a60
diff --git a/src/core/unit.c b/src/core/unit.c
923a60
index 1dff541ac3..b004aa8fcd 100644
923a60
--- a/src/core/unit.c
923a60
+++ b/src/core/unit.c
923a60
@@ -3145,6 +3145,10 @@ void unit_ref_unset(UnitRef *ref) {
923a60
         if (!ref->unit)
923a60
                 return;
923a60
 
923a60
+        /* We are about to drop a reference to the unit, make sure the garbage collection has a look at it as it might
923a60
+         * be unreferenced now. */
923a60
+        unit_add_to_gc_queue(ref->unit);
923a60
+
923a60
         LIST_REMOVE(refs, ref->unit->refs, ref);
923a60
         ref->unit = NULL;
923a60
 }