diff --git a/ixwebsocket/IXSocket.cpp b/ixwebsocket/IXSocket.cpp index 0feb03e1..89fdf888 100644 --- a/ixwebsocket/IXSocket.cpp +++ b/ixwebsocket/IXSocket.cpp @@ -44,12 +44,10 @@ namespace ix close(); } - PollResultType Socket::poll(int timeoutMs) - { - return isReadyToRead(timeoutMs); - } - - PollResultType Socket::select(bool readyToRead, int timeoutMs) + PollResultType Socket::poll(bool readyToRead, + int timeoutMs, + int sockfd, + int interruptFd) { fd_set rfds; fd_set wfds; @@ -57,13 +55,12 @@ namespace ix FD_ZERO(&wfds); fd_set* fds = (readyToRead) ? &rfds : & wfds; - if (_sockfd != -1) + if (sockfd != -1) { - FD_SET(_sockfd, fds); + FD_SET(sockfd, fds); } // File descriptor used to interrupt select when needed - int interruptFd = _selectInterrupt->getFd(); if (interruptFd != -1) { FD_SET(interruptFd, fds); @@ -74,7 +71,6 @@ namespace ix timeout.tv_usec = 1000 * (timeoutMs % 1000); // Compute the highest fd. - int sockfd = _sockfd; int nfds = (std::max)(sockfd, interruptFd); int ret = ::select(nfds + 1, &rfds, &wfds, nullptr, @@ -122,7 +118,7 @@ namespace ix } bool readyToRead = true; - return select(readyToRead, timeoutMs); + return poll(readyToRead, timeoutMs, _sockfd, _selectInterrupt->getFd()); } PollResultType Socket::isReadyToWrite(int timeoutMs) @@ -133,7 +129,7 @@ namespace ix } bool readyToRead = false; - return select(readyToRead, timeoutMs); + return poll(readyToRead, timeoutMs, _sockfd, _selectInterrupt->getFd()); } // Wake up from poll/select by writing to the pipe which is watched by select diff --git a/ixwebsocket/IXSocket.h b/ixwebsocket/IXSocket.h index 193d7b10..9aa1aa5d 100644 --- a/ixwebsocket/IXSocket.h +++ b/ixwebsocket/IXSocket.h @@ -97,7 +97,10 @@ namespace ix std::mutex _socketMutex; private: - PollResultType select(bool readyToRead, int timeoutMs); + PollResultType poll(bool readyToRead, + int timeoutMs, + int sockfd, + int interruptFd); static const int kDefaultPollTimeout; static const int kDefaultPollNoTimeout; diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index cadf7631..99d02c5e 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -330,7 +330,7 @@ namespace ix } // poll the socket - PollResultType pollResult = _socket->poll(lastingTimeoutDelayInMs); + PollResultType pollResult = _socket->isReadyToRead(lastingTimeoutDelayInMs); // Make sure we send all the buffered data // there can be a lot of it for large messages.