--- wepoll/wepoll.c.orig 2020-09-14 20:13:28.000000000 +0200 +++ wepoll/wepoll.c 2020-10-02 00:25:07.000000000 +0200 @@ -1192,6 +1192,7 @@ struct epoll_event* epoll_events, OVERLAPPED_ENTRY* iocp_events, DWORD iocp_event_count) { + bool null_event = false; int epoll_event_count = 0; DWORD i; @@ -1200,10 +1201,16 @@ (IO_STATUS_BLOCK*) iocp_events[i].lpOverlapped; struct epoll_event* ev = &epoll_events[epoll_event_count]; - epoll_event_count += sock_feed_event(port_state, io_status_block, ev); + if (io_status_block) + epoll_event_count += sock_feed_event(port_state, io_status_block, ev); + else + null_event = true; } - return epoll_event_count; + if (null_event && epoll_event_count == 0) + return -2; + else + return epoll_event_count; } static inline int port__poll(port_state_t* port_state, @@ -1282,6 +1289,13 @@ result = port__poll( port_state, events, iocp_events, (DWORD) maxevents, gqcs_timeout); + + /* A single null event was received. */ + if (result == -2) { + result = 0; + break; + } + if (result < 0 || result > 0) break; /* Result, error, or time-out. */