From 41c0bbab130fe5416755caab24897affc28a93e3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 8 Oct 2020 21:14:42 +0200 Subject: [PATCH] event/SocketMonitor: don't filter out ERROR/HANGUP By bit-wise ANDing the reported flags with GetScheduledFlags(), ERROR/HANGUP always get cleared. This means the MPD event loop could never report those conditions. --- src/event/SocketMonitor.cxx | 2 +- src/event/SocketMonitor.hxx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index 018f7330e..5d78d85fe 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -30,7 +30,7 @@ void SocketMonitor::Dispatch(unsigned flags) noexcept { - flags &= GetScheduledFlags(); + flags &= GetScheduledFlags() | IMPLICIT_FLAGS; if (flags != 0) OnSocketReady(flags); diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx index bb1e84354..eb8fcddb6 100644 --- a/src/event/SocketMonitor.hxx +++ b/src/event/SocketMonitor.hxx @@ -57,6 +57,12 @@ public: static constexpr unsigned ERROR = PollGroup::ERROR; static constexpr unsigned HANGUP = PollGroup::HANGUP; + /** + * These flags are always reported by epoll_wait() and don't + * need to be registered with epoll_ctl(). + */ + static constexpr unsigned IMPLICIT_FLAGS = ERROR|HANGUP; + typedef std::make_signed::type ssize_t; explicit SocketMonitor(EventLoop &_loop) noexcept