summaryrefslogtreecommitdiff
path: root/src/core/dbus-timer.c
diff options
context:
space:
mode:
authorKristijan Gjoshev <crypter@mail.com>2020-02-01 18:27:08 +0100
committerAnita Zhang <the.anitazha@gmail.com>2020-11-05 10:59:33 -0800
commitacf24a1a84e9496e3feb09449f4cc43fe67a9a64 (patch)
tree4f0ea72d0e2f6b20aea5c51c489574c63ec0ef81 /src/core/dbus-timer.c
parent5cecbae158ed05b2376a605c9c9ef71eeef81472 (diff)
downloadsystemd-acf24a1a84e9496e3feb09449f4cc43fe67a9a64.tar.gz
timer: add new feature FixedRandomDelay=
FixedRandomDelay=yes will use `siphash24(sd_id128_get_machine() || MANAGER_IS_SYSTEM(m) || getuid() || u->id)`, where || is concatenation, instead of a random number to choose a value between 0 and RandomizedDelaySec= as the timer delay. This essentially sets up a fixed, but seemingly random, offset for each timer iteration rather than having a random offset recalculated each time it fires. Closes #10355 Co-author: Anita Zhang <the.anitazha@gmail.com>
Diffstat (limited to 'src/core/dbus-timer.c')
-rw-r--r--src/core/dbus-timer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c
index da35fa8678..ee54ba8772 100644
--- a/src/core/dbus-timer.c
+++ b/src/core/dbus-timer.c
@@ -131,6 +131,7 @@ const sd_bus_vtable bus_timer_vtable[] = {
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), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("RandomizedDelayUSec", "t", bus_property_get_usec, offsetof(Timer, random_usec), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("FixedRandomDelay", "b", bus_property_get_bool, offsetof(Timer, fixed_random_delay), 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),
@@ -232,6 +233,9 @@ static int bus_timer_set_transient_property(
if (streq(name, "RandomizedDelayUSec"))
return bus_set_transient_usec(u, name, &t->random_usec, message, flags, error);
+ if (streq(name, "FixedRandomDelay"))
+ return bus_set_transient_bool(u, name, &t->fixed_random_delay, message, flags, error);
+
if (streq(name, "WakeSystem"))
return bus_set_transient_bool(u, name, &t->wake_system, message, flags, error);