54 lines
1.9 KiB
Diff
54 lines
1.9 KiB
Diff
From cf0a396c411c78d0d477d2226f89884df207aec2 Mon Sep 17 00:00:00 2001
|
|
From: Lennart Poettering <lennart@poettering.net>
|
|
Date: Mon, 1 Feb 2016 00:19:14 +0100
|
|
Subject: [PATCH 17/20] sd-event: when determining the last allowed time a time
|
|
event may elapse, deal with overflows
|
|
|
|
[commit 1bce0ffa66f329bd50d8bfaa943a755caa65b269 from
|
|
https://github.com/systemd-rhel/rhel-8/]
|
|
|
|
Signed-off-by: Li Zhou <li.zhou@windriver.com>
|
|
---
|
|
src/libsystemd/sd-event/sd-event.c | 10 +++++++---
|
|
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
|
index 6304991..63f77ac 100644
|
|
--- a/src/libsystemd/sd-event/sd-event.c
|
|
+++ b/src/libsystemd/sd-event/sd-event.c
|
|
@@ -302,6 +302,10 @@ static int earliest_time_prioq_compare(const void *a, const void *b) {
|
|
return 0;
|
|
}
|
|
|
|
+static usec_t time_event_source_latest(const sd_event_source *s) {
|
|
+ return usec_add(s->time.next, s->time.accuracy);
|
|
+}
|
|
+
|
|
static int latest_time_prioq_compare(const void *a, const void *b) {
|
|
const sd_event_source *x = a, *y = b;
|
|
|
|
@@ -321,9 +325,9 @@ static int latest_time_prioq_compare(const void *a, const void *b) {
|
|
return 1;
|
|
|
|
/* Order by time */
|
|
- if (x->time.next + x->time.accuracy < y->time.next + y->time.accuracy)
|
|
+ if (time_event_source_latest(x) < time_event_source_latest(y))
|
|
return -1;
|
|
- if (x->time.next + x->time.accuracy > y->time.next + y->time.accuracy)
|
|
+ if (time_event_source_latest(x) > time_event_source_latest(y))
|
|
return 1;
|
|
|
|
return 0;
|
|
@@ -2014,7 +2018,7 @@ static int event_arm_timer(
|
|
b = prioq_peek(d->latest);
|
|
assert_se(b && b->enabled != SD_EVENT_OFF);
|
|
|
|
- t = sleep_between(e, a->time.next, b->time.next + b->time.accuracy);
|
|
+ t = sleep_between(e, a->time.next, time_event_source_latest(b));
|
|
if (d->next == t)
|
|
return 0;
|
|
|
|
--
|
|
2.17.1
|
|
|