chiark / gitweb /
unit: replace recursive_stop by stop_retroactively to simplify things a little
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Oct 2010 01:38:52 +0000 (03:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Oct 2010 01:38:52 +0000 (03:38 +0200)
man/systemd.unit.xml
src/dbus-unit.h
src/device.c
src/load-fragment.c
src/mount.c
src/unit.c
src/unit.h

index f72b947..14da607 100644 (file)
                         </varlistentry>
 
                         <varlistentry>
-                                <term><varname>RecursiveStop=</varname></term>
+                                <term><varname>StopRetroactively=</varname></term>
 
                                 <listitem><para>Takes a boolean
                                 argument. If <option>true</option> and
-                                the unit stops without being requested
-                                by the user, all units
-                                depending on it will be stopped as
+                                a unit this unit requires stops
+                                without this being requested by the
+                                user, this unit will be stopped as
                                 well. (e.g. if a service exits or
-                                crashes on its own behalf, units using
-                                it will be stopped) Note that normally
-                                if a unit stops without a user request,
+                                crashes on its own behalf, units this
+                                flag is set for that require it will
+                                be stopped.) Note that normally if a
+                                unit stops without a user request,
                                 units depending on it will not be
                                 terminated. Only if the user requested
-                                shutdown of a unit, all units depending
-                                on that unit will be shut down as well
-                                and at the same time. Defaults to
+                                shutdown of a unit, all units
+                                depending on that unit will be shut
+                                down as well and at the same
+                                time. Defaults to
                                 <option>false</option>.</para></listitem>
                         </varlistentry>
 
index 94e084f..4a4d23e 100644 (file)
@@ -92,7 +92,7 @@
         "  <property name=\"CanStop\" type=\"b\" access=\"read\"/>\n"   \
         "  <property name=\"CanIsolate\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Job\" type=\"(uo)\" access=\"read\"/>\n"    \
-        "  <property name=\"RecursiveStop\" type=\"b\" access=\"read\"/>\n" \
+        "  <property name=\"StopRetroactively\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"StopWhenUnneeded\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"RefuseManualStart\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"RefuseManualStop\" type=\"b\" access=\"read\"/>\n" \
         { "org.freedesktop.systemd1.Unit", "CanReload",            bus_unit_append_can_reload,     "b",    u                                 }, \
         { "org.freedesktop.systemd1.Unit", "CanIsolate",           bus_unit_append_can_isolate,    "b",    u                                 }, \
         { "org.freedesktop.systemd1.Unit", "Job",                  bus_unit_append_job,            "(uo)", u                                 }, \
-        { "org.freedesktop.systemd1.Unit", "RecursiveStop",        bus_property_append_bool,       "b",    &u->meta.recursive_stop           }, \
+        { "org.freedesktop.systemd1.Unit", "StopRetroactively",    bus_property_append_bool,       "b",    &u->meta.stop_retroactively       }, \
         { "org.freedesktop.systemd1.Unit", "StopWhenUnneeded",     bus_property_append_bool,       "b",    &u->meta.stop_when_unneeded       }, \
         { "org.freedesktop.systemd1.Unit", "RefuseManualStart",    bus_property_append_bool,       "b",    &u->meta.refuse_manual_start      }, \
         { "org.freedesktop.systemd1.Unit", "RefuseManualStop",     bus_property_append_bool,       "b",    &u->meta.refuse_manual_stop       }, \
index 0ddd3b3..7b73110 100644 (file)
@@ -69,12 +69,6 @@ static void device_init(Unit *u) {
          * happen for the other units since their operations time out
          * anyway. */
         d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
-
-        /* We enable recursive stopping by default for all
-        devices. This enables the user to use Requires= to make a
-        service go a way when a device goes away, and Wants=
-        otherwise. */
-        d->meta.recursive_stop = true;
 }
 
 static void device_done(Unit *u) {
index 74fe786..bc34451 100644 (file)
@@ -1769,7 +1769,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "Before",                 config_parse_deps,            UINT_TO_PTR(UNIT_BEFORE),                        "Unit"    },
                 { "After",                  config_parse_deps,            UINT_TO_PTR(UNIT_AFTER),                         "Unit"    },
                 { "OnFailure",              config_parse_deps,            UINT_TO_PTR(UNIT_ON_FAILURE),                    "Unit"    },
-                { "RecursiveStop",          config_parse_bool,            &u->meta.recursive_stop,                         "Unit"    },
+                { "StopRetroactively",      config_parse_bool,            &u->meta.stop_retroactively,                     "Unit"    },
                 { "StopWhenUnneeded",       config_parse_bool,            &u->meta.stop_when_unneeded,                     "Unit"    },
                 { "RefuseManualStart",      config_parse_bool,            &u->meta.refuse_manual_start,                    "Unit"    },
                 { "RefuseManualStop",       config_parse_bool,            &u->meta.refuse_manual_stop,                     "Unit"    },
index d62ce8f..0b67fbe 100644 (file)
@@ -70,6 +70,9 @@ static void mount_init(Unit *u) {
          * already trying to comply its last one. */
         m->exec_context.same_pgrp = true;
 
+        /* Make sure we unmount when the devices we require go away */
+        m->meta.stop_retroactively = true;
+
         m->timer_watch.type = WATCH_INVALID;
 
         m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
index 1775c1d..f080e7b 100644 (file)
@@ -652,13 +652,13 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (u->meta.load_state == UNIT_LOADED) {
                 fprintf(f,
-                        "%s\tRecursive Stop: %s\n"
+                        "%s\tStopRetroactively: %s\n"
                         "%s\tStopWhenUnneeded: %s\n"
                         "%s\tRefuseManualStart: %s\n"
                         "%s\tRefuseManualStop: %s\n"
                         "%s\tDefaultDependencies: %s\n"
                         "%s\tIgnoreDependencyFailure: %s\n",
-                        prefix, yes_no(u->meta.recursive_stop),
+                        prefix, yes_no(u->meta.stop_retroactively),
                         prefix, yes_no(u->meta.stop_when_unneeded),
                         prefix, yes_no(u->meta.refuse_manual_start),
                         prefix, yes_no(u->meta.refuse_manual_stop),
@@ -1011,12 +1011,11 @@ static void retroactively_stop_dependencies(Unit *u) {
         assert(u);
         assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)));
 
-        if (u->meta.recursive_stop) {
-                /* Pull down units need us recursively if enabled */
-                SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
-                        if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
-                                manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
-        }
+        /* Pull down units which need us recursively if enabled */
+        SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
+                if (other->meta.stop_retroactively &&
+                    !UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
+                        manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
 
         /* Garbage collect services that might not be needed anymore, if enabled */
         SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES], i)
index 3f0ef01..8b6b58e 100644 (file)
@@ -105,7 +105,7 @@ enum UnitDependency {
 
         /* Inverse of the above */
         UNIT_REQUIRED_BY,             /* inverse of 'requires' and 'requisite' is 'required_by' */
-        UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'soft_requires' and 'soft_requisite' is 'soft_required_by' */
+        UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */
         UNIT_WANTED_BY,               /* inverse of 'wants' */
 
         /* Negative dependencies */
@@ -191,8 +191,8 @@ struct Meta {
         /* Error code when we didn't manage to load the unit (negative) */
         int load_error;
 
-        /* If we go down, pull down everything that depends on us, too */
-        bool recursive_stop;
+        /* If some required dep goes down, pull down ourselves, too */
+        bool stop_retroactively;
 
         /* Garbage collect us we nobody wants or requires us anymore */
         bool stop_when_unneeded;