summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/dbus-timer.c1
-rw-r--r--src/core/load-fragment-gperf.gperf.m41
-rw-r--r--src/core/timer.c12
-rw-r--r--src/core/timer.h2
4 files changed, 12 insertions, 4 deletions
diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c
index 9e4070a1a3..b7155219ef 100644
--- a/src/core/dbus-timer.c
+++ b/src/core/dbus-timer.c
@@ -143,6 +143,7 @@ const sd_bus_vtable bus_timer_vtable[] = {
SD_BUS_PROPERTY("NextElapseUSecRealtime", "t", bus_property_get_usec, offsetof(Timer, next_elapse_monotonic), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("NextElapseUSecMonotonic", "t", bus_property_get_usec, offsetof(Timer, next_elapse_realtime), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Timer, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+ SD_BUS_PROPERTY("AccuracyUSec", "t", bus_property_get_usec, offsetof(Timer, accuracy_usec), 0),
SD_BUS_VTABLE_END
};
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 22dc536ee1..fbf8381bc1 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -247,6 +247,7 @@ Timer.OnBootSec, config_parse_timer, 0,
Timer.OnStartupSec, config_parse_timer, 0, 0
Timer.OnUnitActiveSec, config_parse_timer, 0, 0
Timer.OnUnitInactiveSec, config_parse_timer, 0, 0
+Timer.AccuracySec, config_parse_sec, 0, offsetof(Timer, accuracy_usec)
Timer.Unit, config_parse_trigger_unit, 0, 0
m4_dnl
Path.PathExists, config_parse_path_spec, 0, 0
diff --git a/src/core/timer.c b/src/core/timer.c
index 5bc01a26ff..f23582c2db 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -47,6 +47,7 @@ static void timer_init(Unit *u) {
t->next_elapse_monotonic = (usec_t) -1;
t->next_elapse_realtime = (usec_t) -1;
+ t->accuracy_usec = USEC_PER_MINUTE;
}
void timer_free_values(Timer *t) {
@@ -144,6 +145,7 @@ static int timer_load(Unit *u) {
}
static void timer_dump(Unit *u, FILE *f, const char *prefix) {
+ char buf[FORMAT_TIMESPAN_MAX];
Timer *t = TIMER(u);
Unit *trigger;
TimerValue *v;
@@ -153,10 +155,12 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) {
fprintf(f,
"%sTimer State: %s\n"
"%sResult: %s\n"
- "%sUnit: %s\n",
+ "%sUnit: %s\n"
+ "%sAccuracy: %s\n",
prefix, timer_state_to_string(t->state),
prefix, timer_result_to_string(t->result),
- prefix, trigger ? trigger->id : "n/a");
+ prefix, trigger ? trigger->id : "n/a",
+ prefix, format_timespan(buf, sizeof(buf), t->accuracy_usec, 1));
LIST_FOREACH(value, v, t->values) {
@@ -346,7 +350,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
r = sd_event_source_set_enabled(t->monotonic_event_source, SD_EVENT_ONESHOT);
} else
- r = sd_event_add_monotonic(UNIT(t)->manager->event, t->next_elapse_monotonic, 0, timer_dispatch, t, &t->monotonic_event_source);
+ r = sd_event_add_monotonic(UNIT(t)->manager->event, t->next_elapse_monotonic, t->accuracy_usec, timer_dispatch, t, &t->monotonic_event_source);
if (r < 0)
goto fail;
@@ -372,7 +376,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
r = sd_event_source_set_enabled(t->realtime_event_source, SD_EVENT_ONESHOT);
} else
- r = sd_event_add_realtime(UNIT(t)->manager->event, t->next_elapse_realtime, 0, timer_dispatch, t, &t->realtime_event_source);
+ r = sd_event_add_realtime(UNIT(t)->manager->event, t->next_elapse_realtime, t->accuracy_usec, timer_dispatch, t, &t->realtime_event_source);
if (r < 0)
goto fail;
diff --git a/src/core/timer.h b/src/core/timer.h
index b3722f0028..3e7efa4c83 100644
--- a/src/core/timer.h
+++ b/src/core/timer.h
@@ -69,6 +69,8 @@ typedef enum TimerResult {
struct Timer {
Unit meta;
+ usec_t accuracy_usec;
+
LIST_HEAD(TimerValue, values);
usec_t next_elapse_monotonic;
usec_t next_elapse_realtime;