X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=f9aca0188ca7abec64229121db6783bcbbf96884;hb=4543768d13946e9193b367330cb32ded4d96058a;hp=b639d686adda3ad13811f21003a6836aeb62282a;hpb=5ad096b3f1331b175340129a8c9a5a9d711e5415;p=elogind.git diff --git a/src/core/unit.c b/src/core/unit.c index b639d686a..f9aca0188 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1456,7 +1456,7 @@ int unit_start(Unit *u) { } if (UNIT_VTABLE(u)->supported && !UNIT_VTABLE(u)->supported(u->manager)) - return -ENOTSUP; + return -EOPNOTSUPP; /* If it is stopped, but we cannot start it, then fail */ if (!UNIT_VTABLE(u)->start) @@ -2856,27 +2856,34 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) { return 0; } -int unit_coldplug(Unit *u) { +static int unit_add_deserialized_job_coldplug(Unit *u) { + int r; + + r = manager_add_job(u->manager, u->deserialized_job, u, JOB_IGNORE_REQUIREMENTS, false, NULL, NULL); + if (r < 0) + return r; + + u->deserialized_job = _JOB_TYPE_INVALID; + + return 0; +} + +int unit_coldplug(Unit *u, Hashmap *deferred_work) { int r; assert(u); if (UNIT_VTABLE(u)->coldplug) - if ((r = UNIT_VTABLE(u)->coldplug(u)) < 0) + if ((r = UNIT_VTABLE(u)->coldplug(u, deferred_work)) < 0) return r; if (u->job) { r = job_coldplug(u->job); if (r < 0) return r; - } else if (u->deserialized_job >= 0) { + } else if (u->deserialized_job >= 0) /* legacy */ - r = manager_add_job(u->manager, u->deserialized_job, u, JOB_IGNORE_REQUIREMENTS, false, NULL, NULL); - if (r < 0) - return r; - - u->deserialized_job = _JOB_TYPE_INVALID; - } + hashmap_put(deferred_work, u, &unit_add_deserialized_job_coldplug); return 0; } @@ -3009,7 +3016,7 @@ int unit_kill(Unit *u, KillWho w, int signo, sd_bus_error *error) { assert(signo < _NSIG); if (!UNIT_VTABLE(u)->kill) - return -ENOTSUP; + return -EOPNOTSUPP; return UNIT_VTABLE(u)->kill(u, w, signo, error); }