From 906e82f600b685d4dd0d93c9910fd052da038941 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Jan 2021 17:26:28 +0100 Subject: [PATCH] event/Loop: fix assertion failure due to wrong "busy" value If an InjectEvent callback schedules a timer, the loop will restart, but the "busy" flag is still false. The fix is to move the "again" check before the "busy" setting. --- src/event/Loop.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index c50727c3a..ea19c2bd9 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -326,15 +326,19 @@ EventLoop::Run() noexcept { const std::lock_guard lock(mutex); HandleInject(); +#endif + + if (again) + /* re-evaluate timers because one of + the DeferEvents may have added a + new timeout */ + continue; + +#ifdef HAVE_THREADED_EVENT_LOOP busy = false; } #endif - if (again) - /* re-evaluate timers because one of the - DeferEvents may have added a new timeout */ - continue; - /* wait for new event */ Wait(timeout);