From b75264b98ffa46d22f86f15b2a025d99112c413d Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Thu, 9 Jan 2020 13:45:58 -0800 Subject: [PATCH] poll: handle POLLNVAL --- ixwebsocket/IXSocket.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ixwebsocket/IXSocket.cpp b/ixwebsocket/IXSocket.cpp index cd6a2016..18d1ccbb 100644 --- a/ixwebsocket/IXSocket.cpp +++ b/ixwebsocket/IXSocket.cpp @@ -59,10 +59,12 @@ namespace ix // nfds_t nfds = 1; struct pollfd fds[2]; - memset(fds, 0 , sizeof(fds)); + memset(fds, 0, sizeof(fds)); fds[0].fd = sockfd; fds[0].events = (readyToRead) ? POLLIN : POLLOUT; + + // this is ignored by poll, but our select based poll wrapper on Windows needs it fds[0].events |= POLLERR; // File descriptor used to interrupt select when needed @@ -133,7 +135,8 @@ namespace ix } #endif } - else if (sockfd != -1 && (fds[0].revents & POLLERR || fds[0].revents & POLLHUP)) + else if (sockfd != -1 && (fds[0].revents & POLLERR || fds[0].revents & POLLHUP || + fds[0].revents & POLLNVAL)) { pollResult = PollResultType::Error; }