]> 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)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 17 May 2025 20:33:09 +0000 (05:33 +0900)
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.

src/core/manager.c

index 4f6232e8ad82ceb9f3a354dd3efc82161b669b7a..ebad062bd3f8286564a21a69d290c9194082cd86 100644 (file)
@@ -1367,7 +1367,6 @@ good:
 
 static unsigned manager_dispatch_gc_unit_queue(Manager *m) {
         unsigned n = 0, gc_marker;
-        Unit *u;
 
         assert(m);
 
@@ -1379,11 +1378,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++;