[systemd-devel] [PATCH] unit: fix unit_stop

Ronny Chevalier rchevalier at aldebaran-robotics.com
Fri Jul 26 07:28:19 PDT 2013


If we don't add the unit to the cleanup queue after it has been
stopped, no UnitRemoved will be sent. Since this signal is only sent
when we free a unit. So we need to add it to the cleanup queue if we
manage to stop it.
---
 src/core/unit.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/core/unit.c b/src/core/unit.c
index 0e9329f..c91c12f 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1171,6 +1171,7 @@ bool unit_can_isolate(Unit *u) {
 int unit_stop(Unit *u) {
         UnitActiveState state;
         Unit *following;
+        int ret;
 
         assert(u);
 
@@ -1192,7 +1193,11 @@ int unit_stop(Unit *u) {
 
         unit_add_to_dbus_queue(u);
 
-        return UNIT_VTABLE(u)->stop(u);
+        ret = UNIT_VTABLE(u)->stop(u);
+        if (ret == 0)
+                unit_add_to_cleanup_queue(u);
+
+        return ret;
 }
 
 /* Errors:
-- 
1.8.3.4



More information about the systemd-devel mailing list