From 935e6229150ac69c489f1938c1149a26e3ae2140 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 5 May 2020 17:08:52 +0200 Subject: [PATCH] event/Loop: allow calling AddFD()... before starting the EventThread Relax the assertions. This is necessary if BlockingCall() is used before the thread is started. --- src/event/Loop.cxx | 4 ++-- src/event/Loop.hxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index c83f652da..d2fed9c4f 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -55,7 +55,7 @@ EventLoop::Break() noexcept bool EventLoop::Abandon(int _fd, SocketMonitor &m) noexcept { - assert(IsInside()); + assert(!IsAlive() || IsInside()); poll_result.Clear(&m); return poll_group.Abandon(_fd); @@ -64,7 +64,7 @@ EventLoop::Abandon(int _fd, SocketMonitor &m) noexcept bool EventLoop::RemoveFD(int _fd, SocketMonitor &m) noexcept { - assert(IsInside()); + assert(!IsAlive() || IsInside()); poll_result.Clear(&m); return poll_group.Remove(_fd); diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx index c13c35ea2..d16f91c57 100644 --- a/src/event/Loop.hxx +++ b/src/event/Loop.hxx @@ -143,13 +143,13 @@ public: void Break() noexcept; bool AddFD(int _fd, unsigned flags, SocketMonitor &m) noexcept { - assert(IsInside()); + assert(!IsAlive() || IsInside()); return poll_group.Add(_fd, flags, &m); } bool ModifyFD(int _fd, unsigned flags, SocketMonitor &m) noexcept { - assert(IsInside()); + assert(!IsAlive() || IsInside()); return poll_group.Modify(_fd, flags, &m); }