From 740cbe9e028814b09cd720d3fe8a117ae2f233cb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 22 May 2023 18:12:54 +0200 Subject: [PATCH] event/Loop: remove failing assert() The `assert(!quit)` can fail if the `EventThread` gets stopped before it enters `EventLoop::Run()`. There is a similar problem with `alive`, which gets reset by `EventThread::Stop()`. If that happens, then `EventLoop::Run()` should return immediately without handling any events. --- src/event/Loop.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index be0f1804b..1b99cd91b 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -272,9 +272,8 @@ EventLoop::Run() noexcept #endif assert(IsInside()); - assert(!quit); #ifdef HAVE_THREADED_EVENT_LOOP - assert(alive); + assert(alive || quit); assert(busy); wake_event.Schedule(SocketEvent::READ); @@ -299,7 +298,7 @@ EventLoop::Run() noexcept steady_clock_cache.flush(); - do { + while (!quit) { again = false; /* invoke timers */ @@ -361,7 +360,7 @@ EventLoop::Run() noexcept socket_event.Dispatch(); } - } while (!quit); + } #ifdef HAVE_THREADED_EVENT_LOOP #ifndef NDEBUG