chiark / gitweb /
unit: fix the race in deserialization.
authorOleksii Shevchuk <alxchk@gmail.com>
Wed, 13 Feb 2013 22:49:26 +0000 (00:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Mar 2013 14:11:35 +0000 (15:11 +0100)
unit_notify is fired in deserelization code (particulary in
service_set_state). Units passed in random order, and there is possibility,
that unit with StopWhenUnneeded=yes passed before it actual dependecies. In
that case unit will be stopped as unneeded, because deps in UNIT_INACTIVE state
yet.

So, reuse similar logic (unit.c:1421) to avoid this race

src/core/unit.c

index e2c06ae8b638123fe2df8d90908fb3f408ea2f75..601be60ed0595311910218a2b916f0ae2112bbf5 100644 (file)
@@ -1517,7 +1517,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
 
         /* Maybe we finished startup and are now ready for being
          * stopped because unneeded? */
-        unit_check_unneeded(u);
+        if (u->manager->n_reloading <= 0)
+                unit_check_unneeded(u);
 
         unit_add_to_dbus_queue(u);
         unit_add_to_gc_queue(u);