summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-11 23:41:21 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-11 23:41:21 +0100
commitba276c8153e510a6741dc8a9492f5bed2b375825 (patch)
tree51b63e0f14253394ac1b4d19eb954934c0473df0 /src/libsystemd-bus
parent21c6dc33a6fc0e8617247fc12123bc667dcde92b (diff)
sd-event: try to move each wakeup to the same spot within every 10s
In addition to the same spot within every 1min, every 1s, every 250s
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/sd-event.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
index 9fceb7b13..462dd413e 100644
--- a/src/libsystemd-bus/sd-event.c
+++ b/src/libsystemd-bus/sd-event.c
@@ -1379,8 +1379,9 @@ static usec_t sleep_between(sd_event *e, usec_t a, usec_t b) {
We implement this by waking up everywhere at the same time
within any given minute if we can, synchronised via the
perturbation value determined from the boot ID. If we can't,
- then we try to find the same spot in every 1s and then 250ms
- step. Otherwise, we pick the last possible time to wake up.
+ then we try to find the same spot in every 10s, then 1s and
+ then 250ms step. Otherwise, we pick the last possible time
+ to wake up.
*/
c = (b / USEC_PER_MINUTE) * USEC_PER_MINUTE + e->perturb;
@@ -1394,6 +1395,17 @@ static usec_t sleep_between(sd_event *e, usec_t a, usec_t b) {
if (c >= a)
return c;
+ c = (b / (USEC_PER_SEC*10)) * (USEC_PER_SEC*10) + (e->perturb % (USEC_PER_SEC*10));
+ if (c >= b) {
+ if (_unlikely_(c < USEC_PER_SEC*10))
+ return b;
+
+ c -= USEC_PER_SEC*10;
+ }
+
+ if (c >= a)
+ return c;
+
c = (b / USEC_PER_SEC) * USEC_PER_SEC + (e->perturb % USEC_PER_SEC);
if (c >= b) {
if (_unlikely_(c < USEC_PER_SEC))