naccyde / rpms / systemd

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