]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: do not GC units/jobs that are in the D-Bus queue 27968/head
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Jun 2023 09:11:49 +0000 (11:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jun 2023 09:16:26 +0000 (11:16 +0200)
Let's make sure that D-Bus messages are always sent out when pending,
before we might GC a unit/job.

This is kinda a follow-up for 8db998981a4fefd0122bcf5f965726b63c9045c2,
and a similar logic really applies: GC should only be done if we
processed everything else, generated evertyhing else and really don't
need it anymore.

src/core/dbus-job.c
src/core/dbus-unit.c
src/core/job.c
src/core/unit.c

index 9792a5c44a1891d34d6c742b862da433cd5ece44..c88d8c2dd5fc3eec11be3581095302df5c120b2e 100644 (file)
@@ -241,6 +241,9 @@ void bus_job_send_change_signal(Job *j) {
         if (j->in_dbus_queue) {
                 LIST_REMOVE(dbus_queue, j->manager->dbus_job_queue, j);
                 j->in_dbus_queue = false;
+
+                /* The job might be good to be GC once its pending signals have been sent */
+                job_add_to_gc_queue(j);
         }
 
         r = bus_foreach_bus(j->manager, j->bus_track, j->sent_dbus_new_signal ? send_changed_signal : send_new_signal, j);
index 59d541ebfe61ecd18a89d1946e52082e6fe48512..629f08ebcc6c04e098d94b9b49001664e2d2afeb 100644 (file)
@@ -1648,6 +1648,9 @@ void bus_unit_send_change_signal(Unit *u) {
         if (u->in_dbus_queue) {
                 LIST_REMOVE(dbus_queue, u->manager->dbus_unit_queue, u);
                 u->in_dbus_queue = false;
+
+                /* The unit might be good to be GC once its pending signals have been sent */
+                unit_add_to_gc_queue(u);
         }
 
         if (!u->id)
index f87b0f7c7471bc5fcb8ca963e4f925be6f184fee..50f9581d727cd5657b851bf73dac99f4ffada2b5 100644 (file)
@@ -1444,6 +1444,10 @@ bool job_may_gc(Job *j) {
         if (!UNIT_VTABLE(j->unit)->gc_jobs)
                 return false;
 
+        /* Make sure to send out pending D-Bus events before we unload the unit */
+        if (j->in_dbus_queue)
+                return false;
+
         if (sd_bus_track_count(j->bus_track) > 0)
                 return false;
 
index 80f398c309c430953e904843b2d34e72ea7c6570..7b2e8c5f5cc2b8fec3a3830cdecd74cee0a0a72f 100644 (file)
@@ -447,6 +447,10 @@ bool unit_may_gc(Unit *u) {
         if (u->in_cgroup_empty_queue || u->in_cgroup_oom_queue)
                 return false;
 
+        /* Make sure to send out D-Bus events before we unload the unit */
+        if (u->in_dbus_queue)
+                return false;
+
         if (sd_bus_track_count(u->bus_track) > 0)
                 return false;