diff --git a/src/socket_poller.cpp b/src/socket_poller.cpp index b9eab821a8..54519cd304 100644 --- a/src/socket_poller.cpp +++ b/src/socket_poller.cpp @@ -559,6 +559,7 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, if (rc == -1 && errno == EINTR) { return -1; } + errno_assert (rc >= 0); // Receive the signal from pollfd diff --git a/src/windows.hpp b/src/windows.hpp index 3ecec4c652..f5abf556b4 100644 --- a/src/windows.hpp +++ b/src/windows.hpp @@ -24,6 +24,7 @@ #endif #endif +#include "err.hpp" #include #include #include @@ -57,7 +58,24 @@ struct tcp_keepalive #if defined ZMQ_IOTHREAD_POLLER_USE_POLL || defined ZMQ_POLL_BASED_ON_POLL static inline int poll (struct pollfd *pfd, unsigned long nfds, int timeout) { - return WSAPoll (pfd, nfds, timeout); + int rc = WSAPoll (pfd, nfds, timeout); + if (rc == -1) { + int wsaError = WSAGetLastError (); + switch (wsaError) { + // let these conditions appear as an interrupted call to + // simplify downstream error processing. + case WSAENETDOWN: + case WSAENOBUFS: + errno = EINTR; + break; + + default: + errno = zmq::wsa_error_to_errno (wsaError); + break; + } + } + + return rc; } #endif