X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fsystemd.git;a=blobdiff_plain;f=socket.c;h=a1f3ef8af75eadb9a637638f88ce494c99a1b0b7;hp=2a19e97b7bc7957af8fb9e5df798c08f840a9eca;hb=23a177ef7c8c38c238ef06666f900f581b48298f;hpb=5af98f828476716954f327c479c4cf6321ae3fe4 diff --git a/socket.c b/socket.c index 2a19e97..a1f3ef8 100644 --- a/socket.c +++ b/socket.c @@ -30,6 +30,8 @@ #include "unit.h" #include "socket.h" #include "log.h" +#include "load-dropin.h" +#include "load-fragment.h" static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = { [SOCKET_DEAD] = UNIT_INACTIVE, @@ -92,7 +94,7 @@ static void socket_done(Unit *u) { unit_unwatch_timer(u, &s->timer_watch); } -static int socket_init(Unit *u) { +static int socket_init(Unit *u, UnitLoadState *new_state) { Socket *s = SOCKET(u); char *t; int r; @@ -109,35 +111,38 @@ static int socket_init(Unit *u) { s->socket_mode = 0666; exec_context_init(&s->exec_context); - if ((r = unit_load_fragment_and_dropin(u)) <= 0) { - if (r == 0) - r = -ENOENT; - goto fail; - } + if ((r = unit_load_fragment(u, new_state)) < 0) + return r; - if (!(t = unit_name_change_suffix(unit_id(u), ".service"))) { - r = -ENOMEM; - goto fail; - } + if (*new_state == UNIT_STUB) + return -ENOENT; - r = manager_load_unit(u->meta.manager, t, (Unit**) &s->service); - free(t); + if ((r = unit_load_dropin(unit_follow_merge(u))) < 0) + return r; - if (r < 0) - goto fail; + /* This is a new unit? Then let's add in some extras */ + if (*new_state == UNIT_LOADED) { - if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(s->service))) < 0) - goto fail; + if (!(t = unit_name_change_suffix(unit_id(u), ".service"))) + return -ENOMEM; - /* Add default cgroup */ - if ((r = unit_add_default_cgroup(u)) < 0) - goto fail; + r = manager_load_unit(u->meta.manager, t, (Unit**) &s->service); + free(t); - return 0; + if (r < 0) + return r; -fail: - socket_done(u); - return r; + if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(s->service))) < 0) + return r; + + if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0) + return r; + + if ((r = unit_add_default_cgroup(u)) < 0) + return r; + } + + return 0; } static const char* listen_lookup(int type) {