X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=target.c;h=c80c09d546b62a46bb97bcb3d65a99a850971443;hp=b18e50fe5bdf756e49f8bee3fd657ff14f2f7fb5;hb=f6ff8c29caeeec3d1f1164be73f87d867d8f1b18;hpb=a7334b0952ab66c17ee787e36e6d2c5ceb387de6 diff --git a/target.c b/target.c index b18e50fe5..c80c09d54 100644 --- a/target.c +++ b/target.c @@ -20,6 +20,7 @@ ***/ #include +#include #include "unit.h" #include "target.h" @@ -36,18 +37,6 @@ static const char* const state_string_table[_TARGET_STATE_MAX] = { [TARGET_ACTIVE] = "active" }; -static int target_init(Unit *u) { - int r; - assert(u); - - /* Make sure this config file actually exists */ - - if ((r = unit_load_fragment_and_dropin(u)) <= 0) - return r < 0 ? r : -ENOENT; - - return 0; -} - static void target_dump(Unit *u, FILE *f, const char *prefix) { Target *t = TARGET(u); @@ -63,6 +52,9 @@ static void target_set_state(Target *t, TargetState state) { TargetState old_state; assert(t); + if (state == t->state) + return; + old_state = t->state; t->state = state; @@ -100,7 +92,7 @@ static UnitActiveState target_active_state(Unit *u) { const UnitVTable target_vtable = { .suffix = ".target", - .init = target_init, + .init = unit_load_fragment_and_dropin, .dump = target_dump,