Skip to content

Commit

Permalink
sd-event: remove assert(a<=b) in sleep_between()
Browse files Browse the repository at this point in the history
With the changes to earliest_time_prioq_compare() to accommodate rate limiting
events, it seems that there can be times where a > b when calculating
sleep_between(). Since the assert() in sleep_between() is no longer true,
remove it and swap a and b when a > b and continue to pick a time between
the two as usual.
  • Loading branch information
anitazha committed Jun 9, 2021
1 parent 3abeeec commit 3e360d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libsystemd/sd-event/sd-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2903,7 +2903,10 @@ static int event_source_leave_ratelimit(sd_event_source *s) {
static usec_t sleep_between(sd_event *e, usec_t a, usec_t b) {
usec_t c;
assert(e);
assert(a <= b);

/* swap a and b such that we always have a <= b */
if (a > b)
SWAP_TWO(a, b);

if (a <= 0)
return 0;
Expand Down

0 comments on commit 3e360d8

Please sign in to comment.