From 68a1e7b5f72058838bd7718b0188ea380df711d6 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Fri, 20 Jan 2023 18:52:14 +0200 Subject: [PATCH] msg: fix poll event driver, handling POLLHUP and POLLERR The poll event driver (mainly used on Windows) is currently ignoring POLLOUT and POLLERR events. Because of this, the caller doesn't get notified that the connection closed and can end up calling "event_wait" indefinitely. This change ensures that POLLOUT and POLLERR events are properly propagated by the poll driver. Related issue: https://github.com/cloudbase/wnbd/issues/98 Signed-off-by: Lucian Petrut --- src/msg/async/EventPoll.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/msg/async/EventPoll.cc b/src/msg/async/EventPoll.cc index dac5e18d403..4c09dbb4db4 100644 --- a/src/msg/async/EventPoll.cc +++ b/src/msg/async/EventPoll.cc @@ -178,6 +178,12 @@ int PollDriver::event_wait(std::vector &fired_events, if (pfds[j].revents & POLLOUT) { mask |= EVENT_WRITABLE; } + if (pfds[j].revents & POLLHUP) { + mask |= EVENT_READABLE | EVENT_WRITABLE; + } + if (pfds[j].revents & POLLERR) { + mask |= EVENT_READABLE | EVENT_WRITABLE; + } if (mask) { fe.fd = pfds[j].fd; fe.mask = mask; -- 2.39.5