diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-17 20:13:36 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-17 20:48:23 +0100 |
commit | 3e0c30ac56269c6fe7b6c0105e7ad826a27d21c6 (patch) | |
tree | 86910d551dad425c918de2a4534a8a51342f92da /src/core/dbus-timer.c | |
parent | df446f96031e281ed676052ccdede0c774cb1e0c (diff) |
core: add RemainAfterElapse= setting to timer units
Previously, after a timer unit elapsed we'd leave it around for good,
which has the nice benefit that starting a timer that shall trigger at a
specific point in time multiple times will only result in one trigger
instead of possibly many. With this change a new option
RemainAfterElapse= is added. It defaults to "true", to mimic the old
behaviour. If set to "false" timer units will be unloaded after they
elapsed. This is specifically useful for transient timer units.
Diffstat (limited to 'src/core/dbus-timer.c')
-rw-r--r-- | src/core/dbus-timer.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c index a8a280d961..2e6c479c3a 100644 --- a/src/core/dbus-timer.c +++ b/src/core/dbus-timer.c @@ -182,6 +182,7 @@ const sd_bus_vtable bus_timer_vtable[] = { SD_BUS_PROPERTY("AccuracyUSec", "t", bus_property_get_usec, offsetof(Timer, accuracy_usec), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Persistent", "b", bus_property_get_bool, offsetof(Timer, persistent), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("WakeSystem", "b", bus_property_get_bool, offsetof(Timer, wake_system), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("RemainAfterElapse", "b", bus_property_get_bool, offsetof(Timer, remain_after_elapse), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_VTABLE_END }; @@ -283,7 +284,6 @@ static int bus_timer_set_transient_property( return 1; } else if (streq(name, "WakeSystem")) { - int b; r = sd_bus_message_read(message, "b", &b); @@ -292,11 +292,24 @@ static int bus_timer_set_transient_property( if (mode != UNIT_CHECK) { t->wake_system = b; - unit_write_drop_in_private_format(UNIT(t), mode, name, "%s=%s\n", name, yes_no(t->wake_system)); + unit_write_drop_in_private_format(UNIT(t), mode, name, "%s=%s\n", name, yes_no(b)); } return 1; + } else if (streq(name, "RemainAfterElapse")) { + int b; + + r = sd_bus_message_read(message, "b", &b); + if (r < 0) + return r; + + if (mode != UNIT_CHECK) { + t->remain_after_elapse = b; + unit_write_drop_in_private_format(UNIT(t), mode, name, "%s=%s\n", name, yes_no(b)); + } + + return 1; } return 0; |