summaryrefslogtreecommitdiff
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-08-31 13:58:29 +0200
committerDaniel Mack <github@zonque.org>2015-08-31 13:58:29 +0200
commitd728d7faa6c60f185be72510d87bcc565bc0846a (patch)
tree4d2ed7404804998cbc10abf0419fac34719c57be /src/core/load-fragment.c
parentabab50081c8c12cc46482a43264deb46853bb8fa (diff)
parentdcd719908229479b0b6ec14d6c1362eb82b1bbf3 (diff)
Merge pull request #1093 from poettering/unified-prepare
A variety of clean-ups
Diffstat (limited to 'src/core/load-fragment.c')
-rw-r--r--src/core/load-fragment.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index b3bf8bdb40..745291c5c6 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2602,7 +2602,7 @@ int config_parse_unit_slice(
void *userdata) {
_cleanup_free_ char *k = NULL;
- Unit *u = userdata, *slice;
+ Unit *u = userdata, *slice = NULL;
int r;
assert(filename);
@@ -2611,29 +2611,23 @@ int config_parse_unit_slice(
assert(u);
r = unit_name_printf(u, rvalue, &k);
- if (r < 0)
- log_syntax(unit, LOG_ERR, filename, line, -r,
- "Failed to resolve unit specifiers on %s. Ignoring.", rvalue);
- if (!k) {
- k = strdup(rvalue);
- if (!k)
- return log_oom();
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers on %s. Ignoring.", rvalue);
+ return 0;
}
r = manager_load_unit(u->manager, k, NULL, NULL, &slice);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r,
- "Failed to load slice unit %s. Ignoring.", k);
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load slice unit %s. Ignoring.", k);
return 0;
}
- if (slice->type != UNIT_SLICE) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Slice unit %s is not a slice. Ignoring.", k);
+ r = unit_set_slice(u, slice);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to assign slice %s to unit %s. Ignoring.", slice->id, u->id);
return 0;
}
- unit_ref_set(&u->slice, slice);
return 0;
}
@@ -3603,6 +3597,11 @@ int unit_load_fragment(Unit *u) {
assert(u->load_state == UNIT_STUB);
assert(u->id);
+ if (u->transient) {
+ u->load_state = UNIT_LOADED;
+ return 0;
+ }
+
/* First, try to find the unit under its id. We always look
* for unit files in the default directories, to make it easy
* to override things by placing things in /etc/systemd/system */