812ca2
From bf370d05bbc8c4d91c8c2b455116e59a24e48911 Mon Sep 17 00:00:00 2001
812ca2
From: Yu Watanabe <watanabe.yu+github@gmail.com>
812ca2
Date: Tue, 15 Jun 2021 02:03:02 +0900
812ca2
Subject: [PATCH] sd-event: make event_source_time_prioq_reshuffle() accept all
812ca2
 event source type
812ca2
812ca2
But it does nothing for an event source which is neither a timer nor
812ca2
ratelimited.
812ca2
812ca2
(cherry picked from commit 5c08c7ab23dbf02aaf4e4bbae8e08a195da230a4)
812ca2
812ca2
Related: #1968528
812ca2
---
812ca2
 src/libsystemd/sd-event/sd-event.c | 9 +++++----
812ca2
 1 file changed, 5 insertions(+), 4 deletions(-)
812ca2
812ca2
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
812ca2
index f675c09d84..ae46392901 100644
812ca2
--- a/src/libsystemd/sd-event/sd-event.c
812ca2
+++ b/src/libsystemd/sd-event/sd-event.c
812ca2
@@ -954,14 +954,15 @@ static void event_source_time_prioq_reshuffle(sd_event_source *s) {
812ca2
         assert(s);
812ca2
 
812ca2
         /* Called whenever the event source's timer ordering properties changed, i.e. time, accuracy,
812ca2
-         * pending, enable state. Makes sure the two prioq's are ordered properly again. */
812ca2
+         * pending, enable state, and ratelimiting state. Makes sure the two prioq's are ordered
812ca2
+         * properly again. */
812ca2
 
812ca2
         if (s->ratelimited)
812ca2
                 d = &s->event->monotonic;
812ca2
-        else {
812ca2
-                assert(EVENT_SOURCE_IS_TIME(s->type));
812ca2
+        else if (EVENT_SOURCE_IS_TIME(s->type))
812ca2
                 assert_se(d = event_get_clock_data(s->event, s->type));
812ca2
-        }
812ca2
+        else
812ca2
+                return; /* no-op for an event source which is neither a timer nor ratelimited. */
812ca2
 
812ca2
         prioq_reshuffle(d->earliest, s, &s->earliest_index);
812ca2
         prioq_reshuffle(d->latest, s, &s->latest_index);