From f1194f5d592019e26a682695e1040612ec1d97b7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 21 Nov 2019 12:14:58 +0100 Subject: [PATCH] varlink: fix enablement of varlink timeout event source --- src/shared/varlink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shared/varlink.c b/src/shared/varlink.c index 55098a1212f..ee4fb9e8439 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -1831,6 +1831,7 @@ static int prepare_callback(sd_event_source *s, void *userdata) { Varlink *v = userdata; int r, e; usec_t until; + bool have_timeout; assert(s); assert(v); @@ -1846,13 +1847,15 @@ static int prepare_callback(sd_event_source *s, void *userdata) { r = varlink_get_timeout(v, &until); if (r < 0) return r; - if (r > 0) { + have_timeout = r > 0; + + if (have_timeout) { r = sd_event_source_set_time(v->time_event_source, until); if (r < 0) return r; } - r = sd_event_source_set_enabled(v->time_event_source, r > 0 ? SD_EVENT_ON : SD_EVENT_OFF); + r = sd_event_source_set_enabled(v->time_event_source, have_timeout ? SD_EVENT_ON : SD_EVENT_OFF); if (r < 0) return r;