summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-06-15 02:13:59 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-23 16:58:34 +0200
commit0db66a9bb5b37d47a0ff210e628589e4255df283 (patch)
tree41185fb2e1f67b626f648702bada0570cfc699c0
parent63f3d322f0b63ccf655fa554484124696f388041 (diff)
downloadsystemd-248.6.tar.gz
sd-event: always reshuffle time prioq on changing online/offline statev248.6
Before 81107b8419c39f726fd2805517a5b9faab204e59, the compare functions for the latest or earliest prioq did not handle ratelimited flag. So, it was ok to not reshuffle the time prioq when changing the flag. But now, those two compare functions also compare the source is ratelimited or not. So, it is necessary to reshuffle the time prioq after changing the ratelimited flag. Hopefully fixes #19903. (cherry picked from commit 2115b9b6629eeba7bc9f42f757f38205febb1cb7) Hopefully fixes #20285 and https://bugzilla.redhat.com/show_bug.cgi?id=1984651.
-rw-r--r--src/libsystemd/sd-event/sd-event.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 521c499ca2..0d7740f1a4 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2380,14 +2380,6 @@ static int event_source_offline(
source_io_unregister(s);
break;
- case SOURCE_TIME_REALTIME:
- case SOURCE_TIME_BOOTTIME:
- case SOURCE_TIME_MONOTONIC:
- case SOURCE_TIME_REALTIME_ALARM:
- case SOURCE_TIME_BOOTTIME_ALARM:
- event_source_time_prioq_reshuffle(s);
- break;
-
case SOURCE_SIGNAL:
event_gc_signal_data(s->event, &s->priority, s->signal.sig);
break;
@@ -2408,6 +2400,11 @@ static int event_source_offline(
prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
break;
+ case SOURCE_TIME_REALTIME:
+ case SOURCE_TIME_BOOTTIME:
+ case SOURCE_TIME_MONOTONIC:
+ case SOURCE_TIME_REALTIME_ALARM:
+ case SOURCE_TIME_BOOTTIME_ALARM:
case SOURCE_DEFER:
case SOURCE_POST:
case SOURCE_INOTIFY:
@@ -2417,6 +2414,9 @@ static int event_source_offline(
assert_not_reached("Wut? I shouldn't exist.");
}
+ /* Always reshuffle time prioq, as the ratelimited flag may be changed. */
+ event_source_time_prioq_reshuffle(s);
+
return 1;
}
@@ -2506,22 +2506,11 @@ static int event_source_online(
s->ratelimited = ratelimited;
/* Non-failing operations below */
- switch (s->type) {
- case SOURCE_TIME_REALTIME:
- case SOURCE_TIME_BOOTTIME:
- case SOURCE_TIME_MONOTONIC:
- case SOURCE_TIME_REALTIME_ALARM:
- case SOURCE_TIME_BOOTTIME_ALARM:
- event_source_time_prioq_reshuffle(s);
- break;
-
- case SOURCE_EXIT:
+ if (s->type == SOURCE_EXIT)
prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index);
- break;
- default:
- break;
- }
+ /* Always reshuffle time prioq, as the ratelimited flag may be changed. */
+ event_source_time_prioq_reshuffle(s);
return 1;
}