summaryrefslogtreecommitdiff
path: root/node/SocketManager.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2014-03-28 13:37:21 -0700
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2014-03-28 13:37:21 -0700
commit7957ab6b1df2c5221d702d205397365fcbe93d98 (patch)
treea6dcecfd1ed0ed438317d778de796bafb266cf7d /node/SocketManager.cpp
parente8b613e625d18a03d14073e4634cdfb64e120d38 (diff)
downloadinfinitytier-7957ab6b1df2c5221d702d205397365fcbe93d98.tar.gz
infinitytier-7957ab6b1df2c5221d702d205397365fcbe93d98.zip
Windows uses exceptfds to report failed async connect() in select(). TCP now done on Windows (I think).
Diffstat (limited to 'node/SocketManager.cpp')
-rw-r--r--node/SocketManager.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/node/SocketManager.cpp b/node/SocketManager.cpp
index 41facdc0..722db5b1 100644
--- a/node/SocketManager.cpp
+++ b/node/SocketManager.cpp
@@ -459,6 +459,17 @@ void SocketManager::poll(unsigned long timeout)
_fdSetLock.unlock();
FD_ZERO(&efds);
+#ifdef __WINDOWS__
+ // Windows signals failed connects in exceptfds
+ {
+ Mutex::Lock _l2(_tcpSockets_m);
+ for(std::map< InetAddress,SharedPtr<Socket> >::iterator s(_tcpSockets.begin());s!=_tcpSockets.end();++s) {
+ if (((TcpSocket *)s->second.ptr())->_connecting)
+ FD_SET(s->second->_sock,&efds);
+ }
+ }
+#endif
+
tv.tv_sec = (long)(timeout / 1000);
tv.tv_usec = (long)((timeout % 1000) * 1000);
select(_nfds + 1,&rfds,&wfds,&efds,(timeout > 0) ? &tv : (struct timeval *)0);
@@ -567,7 +578,11 @@ void SocketManager::poll(unsigned long timeout)
ts.reserve(_tcpSockets.size());
uint64_t now = Utils::now();
for(std::map< InetAddress,SharedPtr<Socket> >::iterator s(_tcpSockets.begin());s!=_tcpSockets.end();) {
+#ifdef __WINDOWS__
+ if ( ((now - ((TcpSocket *)s->second.ptr())->_lastActivity) < ZT_TCP_TUNNEL_ACTIVITY_TIMEOUT) && (! ((((TcpSocket *)s->second.ptr())->_connecting)&&(FD_ISSET(s->second->_sock,&efds))) ) ) {
+#else
if ((now - ((TcpSocket *)s->second.ptr())->_lastActivity) < ZT_TCP_TUNNEL_ACTIVITY_TIMEOUT) {
+#endif
ts.push_back(s->second);
++s;
} else {