summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-09-07 02:59:08 +0200
committerTom Gundersen <teg@jklm.no>2015-09-07 02:59:08 +0200
commit6167a91c745e5406164ef57e27212ba572d9a0dc (patch)
tree35af349cc76d850d1593163d8dabfd4c59dfe267 /src/core/unit.c
parent2009bcfd23400bacd50848ac3e72cd5f6fbe53db (diff)
parent08acb521f30d692f13056daa23fb1323528249ff (diff)
Merge pull request #1165 from poettering/nspawn-files
various fixes to the core, logind, machined, nspawn
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index a5714adf38..45ce1b172d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1416,9 +1416,14 @@ int unit_start(Unit *u) {
assert(u);
+ /* Units that aren't loaded cannot be started */
if (u->load_state != UNIT_LOADED)
return -EINVAL;
+ /* Units of types that aren't supported annot be started either */
+ if (!unit_supported(u))
+ return -EOPNOTSUPP;
+
/* If this is already 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
@@ -1451,9 +1456,6 @@ int unit_start(Unit *u) {
return unit_start(following);
}
- if (!unit_supported(u))
- return -EOPNOTSUPP;
-
/* If it is stopped, but we cannot start it, then fail */
if (!UNIT_VTABLE(u)->start)
return -EBADR;
@@ -1472,6 +1474,12 @@ int unit_start(Unit *u) {
bool unit_can_start(Unit *u) {
assert(u);
+ if (u->load_state != UNIT_LOADED)
+ return false;
+
+ if (!unit_supported(u))
+ return false;
+
return !!UNIT_VTABLE(u)->start;
}