]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/manager: do not pop gc_unit_queue before unit_gc_sweep()
authorMike Yuan <me@yhndnzj.com>
Sat, 17 May 2025 14:59:32 +0000 (16:59 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 28 May 2025 18:16:16 +0000 (19:16 +0100)
Follow-up for 52e3671bf7e6321c58c6d3a6c8ad8e167259a569

unit_gc_sweep() might try to add the unit to gc queue again.
While that becomes no-op as Unit.in_gc_queue is not cleared
yet, it induces minor inconsistency of states.

(cherry picked from commit 741a184a31127305fb4363833ca9d97a1057fc68)
(cherry picked from commit 9645e946f9e323965116d89fce8009cc86418c9d)

src/core/manager.c

index 02d7b9d5a6b6a2f27b6a2a89c48dbad0084b7f87..106e5e0b9e4462d1c4b3615d3d070e599f16ebd7 100644 (file)
@@ -1413,7 +1413,6 @@ good:
 
 static unsigned manager_dispatch_gc_unit_queue(Manager *m) {
         unsigned n = 0, gc_marker;
-        Unit *u;
 
         assert(m);
 
@@ -1425,11 +1424,13 @@ static unsigned manager_dispatch_gc_unit_queue(Manager *m) {
 
         gc_marker = m->gc_marker;
 
-        while ((u = LIST_POP(gc_queue, m->gc_unit_queue))) {
+        Unit *u;
+        while ((u = m->gc_unit_queue)) {
                 assert(u->in_gc_queue);
 
                 unit_gc_sweep(u, gc_marker);
 
+                LIST_REMOVE(gc_queue, m->gc_unit_queue, u);
                 u->in_gc_queue = false;
 
                 n++;