1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

sd-event: don't mistake USEC_INFINITY passed in for overflow

Let's pass USEC_INFINITY from sd_event_source_set_time_relative() to
sd_event_source_set_time() instead of raising EOVERFLOW.

We should raise EOVERFLOW only if your addition fails, but not if the
input already is USEC_INFINITY, since it's an entirely valid operation
to have an infinite time-out, and we should support that.

(cherry picked from commit ef8591951a)
(cherry picked from commit 9769d84fe5)
This commit is contained in:
Lennart Poettering 2023-01-06 11:27:17 +01:00 committed by Luca Boccassi
parent b33fbceef9
commit 5fe49d0fb8

View File

@ -2655,6 +2655,9 @@ _public_ int sd_event_source_set_time_relative(sd_event_source *s, uint64_t usec
assert_return(s, -EINVAL);
assert_return(EVENT_SOURCE_IS_TIME(s->type), -EDOM);
if (usec == USEC_INFINITY)
return sd_event_source_set_time(s, USEC_INFINITY);
r = sd_event_now(s->event, event_source_type_to_clock(s->type), &t);
if (r < 0)
return r;