From 15e8c181063ecd32b2dc2eec9185d976005e0c43 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 19 Mar 2014 22:01:32 -0700 Subject: Bug fixes. --- node/SocketManager.hpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'node/SocketManager.hpp') diff --git a/node/SocketManager.hpp b/node/SocketManager.hpp index 9f980e37..e6e87a1f 100644 --- a/node/SocketManager.hpp +++ b/node/SocketManager.hpp @@ -169,6 +169,27 @@ private: #endif } + inline void _updateNfds() + { + int nfds = _whackSendPipe; + if (_whackReceivePipe > nfds) + nfds = _whackReceivePipe; + if (_tcpV4ListenSocket > nfds) + nfds = _tcpV4ListenSocket; + if (_tcpV6ListenSocket > nfds) + nfds = _tcpV6ListenSocket; + if ((_udpV4Socket)&&(_udpV4Socket->_sock > nfds)) + nfds = _udpV4Socket->_sock; + if ((_udpV6Socket)&&(_udpV6Socket->_sock > nfds)) + nfds = _udpV6Socket->_sock; + Mutex::Lock _l(_tcpSockets_m); + for(std::map< InetAddress,SharedPtr >::const_iterator s(_tcpSockets.begin());s!=_tcpSockets.end();++s) { + if (s->second->_sock > nfds) + nfds = s->second->_sock; + } + _nfds = nfds; + } + #ifdef __WINDOWS__ SOCKET _whackSendPipe; SOCKET _whackReceivePipe; @@ -187,7 +208,7 @@ private: fd_set _readfds; fd_set _writefds; - int _nfds; + volatile int _nfds; Mutex _fdSetLock; std::map< InetAddress,SharedPtr > _tcpSockets; -- cgit v1.2.3