Skip to content

Commit

Permalink
sd-event: always reshuffle time prioq on changing online/offline state
Browse files Browse the repository at this point in the history
Before 81107b8, 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.
  • Loading branch information
yuwata committed Jun 14, 2021
1 parent 5c08c7a commit 2115b9b
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions src/libsystemd/sd-event/sd-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2370,14 +2370,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;
Expand All @@ -2398,6 +2390,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:
Expand All @@ -2407,6 +2404,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;
}

Expand Down Expand Up @@ -2496,22 +2496,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;
}
Expand Down

0 comments on commit 2115b9b

Please sign in to comment.