chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix spelling of 'unneeded' at various places
[elogind.git]
/
src
/
timer.c
diff --git
a/src/timer.c
b/src/timer.c
index 1580478949595cd0a6006fd0360ad8103d497efc..ff94b8c8693a70d659052e5c53eb0a5de02f095f 100644
(file)
--- a/
src/timer.c
+++ b/
src/timer.c
@@
-1,4
+1,4
@@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8
; indent-tabs-mode: nil
-*-*/
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-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) {
@@
-82,7
+82,7
@@
static int timer_add_default_dependencies(Timer *t) {
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
S
, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+ return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICT
ED_BY
, SPECIAL_SHUTDOWN_TARGET, NULL, true);
}
static int timer_load(Unit *u) {
}
static int timer_load(Unit *u) {
@@
-114,15
+114,10
@@
static int timer_load(Unit *u) {
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
Timer *t = TIMER(u);
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
Timer *t = TIMER(u);
- const char *prefix2;
- char *p2;
TimerValue *v;
char
timespan1[FORMAT_TIMESPAN_MAX];
TimerValue *v;
char
timespan1[FORMAT_TIMESPAN_MAX];
- p2 = strappend(prefix, "\t");
- prefix2 = p2 ? p2 : prefix;
-
fprintf(f,
"%sTimer State: %s\n"
"%sUnit: %s\n",
fprintf(f,
"%sTimer State: %s\n"
"%sUnit: %s\n",
@@
-135,8
+130,6
@@
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
prefix,
timer_base_to_string(v->base),
strna(format_timespan(timespan1, sizeof(timespan1), v->value)));
prefix,
timer_base_to_string(v->base),
strna(format_timespan(timespan1, sizeof(timespan1), v->value)));
-
- free(p2);
}
static void timer_set_state(Timer *t, TimerState state) {
}
static void timer_set_state(Timer *t, TimerState state) {
@@
-185,7
+178,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) {
@@
-300,7
+293,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;
@@
-428,7
+421,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);
}
@@
-436,7
+429,7
@@
void timer_unit_notify(Unit *u, UnitActiveState new_state) {
break;
case TIMER_DEAD:
break;
case TIMER_DEAD:
- case TIMER_
MAINTENANCE
:
+ case TIMER_
FAILED
:
;
default:
;
default:
@@
-450,12
+443,23
@@
fail:
log_error("Failed find timer unit: %s", strerror(-r));
}
log_error("Failed find timer unit: %s", strerror(-r));
}
+static void timer_reset_failed(Unit *u) {
+ Timer *t = TIMER(u);
+
+ assert(t);
+
+ if (t->state == TIMER_FAILED)
+ timer_set_state(t, TIMER_DEAD);
+
+ t->failure = false;
+}
+
static const char* const timer_state_table[_TIMER_STATE_MAX] = {
[TIMER_DEAD] = "dead",
[TIMER_WAITING] = "waiting",
[TIMER_RUNNING] = "running",
[TIMER_ELAPSED] = "elapsed",
static const char* const timer_state_table[_TIMER_STATE_MAX] = {
[TIMER_DEAD] = "dead",
[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);
@@
-492,5
+496,9
@@
const UnitVTable timer_vtable = {
.timer_event = timer_timer_event,
.timer_event = timer_timer_event,
- .bus_message_handler = bus_timer_message_handler
+ .reset_failed = timer_reset_failed,
+
+ .bus_interface = "org.freedesktop.systemd1.Timer",
+ .bus_message_handler = bus_timer_message_handler,
+ .bus_invalidating_properties = bus_timer_invalidating_properties
};
};