summaryrefslogtreecommitdiff
path: root/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-12 02:40:28 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-12 02:40:28 +0100
commit7898b0cf7ec1a30454538b415e25d544ecee5d5b (patch)
tree9950aaf0aeeaa0e96789709ddb3c6acf45725801 /unit.c
parentc0dafa4853b52741e9a4845419c00611426cefd8 (diff)
unit: if start is called for a non-startable service and it is around, return EALREADY, don't refuse
Diffstat (limited to 'unit.c')
-rw-r--r--unit.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/unit.c b/unit.c
index c27e4ec902..cb9fe7cdaa 100644
--- a/unit.c
+++ b/unit.c
@@ -478,13 +478,18 @@ int unit_start(Unit *u) {
assert(u);
- if (!UNIT_VTABLE(u)->start)
- return -EBADR;
-
+ /* If this is already (being) started, then this will
+ * succeed. Note that this will even succeed if this unit is
+ * not startable by the user. This is relied on to detect when
+ * we need to wait for units and when waiting is finished. */
state = unit_active_state(u);
if (UNIT_IS_ACTIVE_OR_RELOADING(state))
return -EALREADY;
+ /* If it is stopped, but we cannot start it, then fail */
+ if (!UNIT_VTABLE(u)->start)
+ return -EBADR;
+
/* We don't suppress calls to ->start() here when we are
* already starting, to allow this request to be used as a
* "hurry up" call, for example when the unit is in some "auto
@@ -511,13 +516,13 @@ int unit_stop(Unit *u) {
assert(u);
- if (!UNIT_VTABLE(u)->stop)
- return -EBADR;
-
state = unit_active_state(u);
if (state == UNIT_INACTIVE)
return -EALREADY;
+ if (!UNIT_VTABLE(u)->stop)
+ return -EBADR;
+
if (state == UNIT_DEACTIVATING)
return 0;