From caac69a0cb677420b2cd4d33423d60a723821dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Sat, 22 Jun 2019 13:47:31 +0200 Subject: [PATCH] fixed GH #2313: PollSet behaves differently on windows --- Net/src/PollSet.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Net/src/PollSet.cpp b/Net/src/PollSet.cpp index 9dcbf878e..57d481d23 100644 --- a/Net/src/PollSet.cpp +++ b/Net/src/PollSet.cpp @@ -72,7 +72,8 @@ public: { Poco::FastMutex::ScopedLock lock(_mutex); - poco_socket_t fd = socket.impl()->sockfd(); + SocketImpl* sockImpl = socket.impl(); + poco_socket_t fd = sockImpl->sockfd(); struct epoll_event ev; ev.events = 0; if (mode & PollSet::POLL_READ) @@ -83,9 +84,15 @@ public: ev.events |= EPOLLERR; ev.data.ptr = socket.impl(); int err = epoll_ctl(_epollfd, EPOLL_CTL_ADD, fd, &ev); - if (err) SocketImpl::error(); - _socketMap[socket.impl()] = socket; + if (err) + { + if (errno == EEXIST) update(socket, mode); + else SocketImpl::error(); + } + + if (_socketMap.find(sockImpl) == _socketMap.end()) + _socketMap[sockImpl] = socket; } void remove(const Socket& socket) @@ -320,6 +327,10 @@ public: result[its->second] |= PollSet::POLL_WRITE; if (it->revents & POLLERR) result[its->second] |= PollSet::POLL_ERROR; +#ifdef _WIN32 + if (it->revents & POLLHUP) + result[its->second] |= PollSet::POLL_READ; +#endif } it->revents = 0; }