-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "dbus-target.h"
+#include "dbus-unit.h"
#include "log.h"
+#include "serialize.h"
#include "special.h"
#include "string-util.h"
+#include "target.h"
#include "unit-name.h"
#include "unit.h"
-#include "target.h"
static const UnitActiveState state_translation_table[_TARGET_STATE_MAX] = {
[TARGET_DEAD] = UNIT_INACTIVE,
TargetState old_state;
assert(t);
+ if (t->state != state)
+ bus_unit_send_pending_change_signal(UNIT(t), false);
+
old_state = t->state;
t->state = state;
for (k = 0; k < ELEMENTSOF(deps); k++) {
Unit *other;
- Iterator i;
void *v;
- HASHMAP_FOREACH_KEY(v, other, UNIT(t)->dependencies[deps[k]], i) {
+ HASHMAP_FOREACH_KEY(v, other, UNIT(t)->dependencies[deps[k]]) {
r = unit_add_default_target_dependency(other, UNIT(t));
if (r < 0)
return r;
return 0;
/* Make sure targets are unloaded on shutdown */
- return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true, UNIT_DEPENDENCY_DEFAULT);
+ return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
}
static int target_load(Unit *u) {
assert(t);
- r = unit_load_fragment_and_dropin(u);
+ r = unit_load_fragment_and_dropin(u, true);
if (r < 0)
return r;
- /* This is a new unit? Then let's add in some extras */
- if (u->load_state == UNIT_LOADED) {
- r = target_add_default_dependencies(t);
- if (r < 0)
- return r;
- }
+ if (u->load_state != UNIT_LOADED)
+ return 0;
- return 0;
+ /* This is a new unit? Then let's add in some extras */
+ return target_add_default_dependencies(t);
}
static int target_coldplug(Unit *u) {
assert(f);
assert(fds);
- unit_serialize_item(u, f, "state", target_state_to_string(s->state));
+ (void) serialize_item(f, "state", target_state_to_string(s->state));
return 0;
}
"Target\0"
"Install\0",
+ .can_fail = true,
+
.load = target_load,
.coldplug = target_coldplug,
.active_state = target_active_state,
.sub_state_to_string = target_sub_state_to_string,
- .bus_vtable = bus_target_vtable,
-
.status_message_formats = {
.finished_start_job = {
[JOB_DONE] = "Reached target %s.",