chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
random: do not print warning if random seed doesn't exist yet
[elogind.git]
/
src
/
timer.c
diff --git
a/src/timer.c
b/src/timer.c
index 89deb0194a7c3b6baf3c60ff8396630d947612bd..1477aa5256d622412180fb9ffdb02e0f17a2329d 100644
(file)
--- a/
src/timer.c
+++ b/
src/timer.c
@@
-33,7
+33,7
@@
static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
[TIMER_WAITING] = UNIT_ACTIVE,
[TIMER_RUNNING] = UNIT_ACTIVE,
[TIMER_ELAPSED] = UNIT_ACTIVE,
[TIMER_WAITING] = UNIT_ACTIVE,
[TIMER_RUNNING] = UNIT_ACTIVE,
[TIMER_ELAPSED] = UNIT_ACTIVE,
- [TIMER_
MAINTENANCE] = UNIT_MAINTENANCE
+ [TIMER_
FAILED] = UNIT_FAILED
};
static void timer_init(Unit *u) {
};
static void timer_init(Unit *u) {
@@
-78,11
+78,15
@@
static int timer_add_default_dependencies(Timer *t) {
assert(t);
assert(t);
- if (t->meta.manager->running_as == MANAGER_SYSTEM)
+ if (t->meta.manager->running_as == MANAGER_SYSTEM) {
+ if ((r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
+ return r;
+
if ((r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
return r;
if ((r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
return r;
+ }
- return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICT
ED_BY
, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+ return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICT
S
, SPECIAL_SHUTDOWN_TARGET, NULL, true);
}
static int timer_load(Unit *u) {
}
static int timer_load(Unit *u) {
@@
-148,7
+152,7
@@
static void timer_set_state(Timer *t, TimerState state) {
timer_state_to_string(old_state),
timer_state_to_string(state));
timer_state_to_string(old_state),
timer_state_to_string(state));
- unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state]);
+ unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state]
, true
);
}
static void timer_enter_waiting(Timer *t, bool initial);
}
static void timer_enter_waiting(Timer *t, bool initial);
@@
-161,9
+165,7
@@
static int timer_coldplug(Unit *u) {
if (t->deserialized_state != t->state) {
if (t->deserialized_state != t->state) {
- if (t->deserialized_state == TIMER_WAITING ||
- t->deserialized_state == TIMER_RUNNING ||
- t->deserialized_state == TIMER_ELAPSED)
+ if (t->deserialized_state == TIMER_WAITING)
timer_enter_waiting(t, false);
else
timer_set_state(t, t->deserialized_state);
timer_enter_waiting(t, false);
else
timer_set_state(t, t->deserialized_state);
@@
-178,7
+180,7
@@
static void timer_enter_dead(Timer *t, bool success) {
if (!success)
t->failure = true;
if (!success)
t->failure = true;
- timer_set_state(t, t->failure ? TIMER_
MAINTENANCE
: TIMER_DEAD);
+ timer_set_state(t, t->failure ? TIMER_
FAILED
: TIMER_DEAD);
}
static void timer_enter_waiting(Timer *t, bool initial) {
}
static void timer_enter_waiting(Timer *t, bool initial) {
@@
-197,9
+199,9
@@
static void timer_enter_waiting(Timer *t, bool initial) {
switch (v->base) {
case TIMER_ACTIVE:
switch (v->base) {
case TIMER_ACTIVE:
- if (state_translation_table[t->state] == UNIT_ACTIVE)
{
+ if (state_translation_table[t->state] == UNIT_ACTIVE)
base = t->meta.inactive_exit_timestamp.monotonic;
base = t->meta.inactive_exit_timestamp.monotonic;
-
}
else
+ else
base = n;
break;
base = n;
break;
@@
-293,7
+295,7
@@
static int timer_start(Unit *u) {
Timer *t = TIMER(u);
assert(t);
Timer *t = TIMER(u);
assert(t);
- assert(t->state == TIMER_DEAD || t->state == TIMER_
MAINTENANCE
);
+ assert(t->state == TIMER_DEAD || t->state == TIMER_
FAILED
);
if (t->unit->meta.load_state != UNIT_LOADED)
return -ENOENT;
if (t->unit->meta.load_state != UNIT_LOADED)
return -ENOENT;
@@
-421,7
+423,7
@@
void timer_unit_notify(Unit *u, UnitActiveState new_state) {
case TIMER_RUNNING:
case TIMER_RUNNING:
- if (UNIT_IS_INACTIVE_OR_
MAINTENANCE
(new_state)) {
+ if (UNIT_IS_INACTIVE_OR_
FAILED
(new_state)) {
log_debug("%s got notified about unit deactivation.", t->meta.id);
timer_enter_waiting(t, false);
}
log_debug("%s got notified about unit deactivation.", t->meta.id);
timer_enter_waiting(t, false);
}
@@
-429,8
+431,8
@@
void timer_unit_notify(Unit *u, UnitActiveState new_state) {
break;
case TIMER_DEAD:
break;
case TIMER_DEAD:
- case TIMER_
MAINTENANCE
:
- ;
+ case TIMER_
FAILED
:
+
break
;
default:
assert_not_reached("Unknown timer state");
default:
assert_not_reached("Unknown timer state");
@@
-443,12
+445,12
@@
fail:
log_error("Failed find timer unit: %s", strerror(-r));
}
log_error("Failed find timer unit: %s", strerror(-r));
}
-static void timer_reset_
maintenance
(Unit *u) {
+static void timer_reset_
failed
(Unit *u) {
Timer *t = TIMER(u);
assert(t);
Timer *t = TIMER(u);
assert(t);
- if (t->state == TIMER_
MAINTENANCE
)
+ if (t->state == TIMER_
FAILED
)
timer_set_state(t, TIMER_DEAD);
t->failure = false;
timer_set_state(t, TIMER_DEAD);
t->failure = false;
@@
-459,7
+461,7
@@
static const char* const timer_state_table[_TIMER_STATE_MAX] = {
[TIMER_WAITING] = "waiting",
[TIMER_RUNNING] = "running",
[TIMER_ELAPSED] = "elapsed",
[TIMER_WAITING] = "waiting",
[TIMER_RUNNING] = "running",
[TIMER_ELAPSED] = "elapsed",
- [TIMER_
MAINTENANCE] = "maintenance
"
+ [TIMER_
FAILED] = "failed
"
};
DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState);
};
DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState);
@@
-496,7
+498,7
@@
const UnitVTable timer_vtable = {
.timer_event = timer_timer_event,
.timer_event = timer_timer_event,
- .reset_
maintenance = timer_reset_maintenance
,
+ .reset_
failed = timer_reset_failed
,
.bus_interface = "org.freedesktop.systemd1.Timer",
.bus_message_handler = bus_timer_message_handler,
.bus_interface = "org.freedesktop.systemd1.Timer",
.bus_message_handler = bus_timer_message_handler,