mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Windows uses exceptfds to report failed async connect() in select(). TCP now done on Windows (I think).
This commit is contained in:
parent
e8b613e625
commit
7957ab6b1d
3 changed files with 20 additions and 2 deletions
|
@ -459,6 +459,17 @@ void SocketManager::poll(unsigned long timeout)
|
||||||
_fdSetLock.unlock();
|
_fdSetLock.unlock();
|
||||||
FD_ZERO(&efds);
|
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_sec = (long)(timeout / 1000);
|
||||||
tv.tv_usec = (long)((timeout % 1000) * 1000);
|
tv.tv_usec = (long)((timeout % 1000) * 1000);
|
||||||
select(_nfds + 1,&rfds,&wfds,&efds,(timeout > 0) ? &tv : (struct timeval *)0);
|
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());
|
ts.reserve(_tcpSockets.size());
|
||||||
uint64_t now = Utils::now();
|
uint64_t now = Utils::now();
|
||||||
for(std::map< InetAddress,SharedPtr<Socket> >::iterator s(_tcpSockets.begin());s!=_tcpSockets.end();) {
|
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) {
|
if ((now - ((TcpSocket *)s->second.ptr())->_lastActivity) < ZT_TCP_TUNNEL_ACTIVITY_TIMEOUT) {
|
||||||
|
#endif
|
||||||
ts.push_back(s->second);
|
ts.push_back(s->second);
|
||||||
++s;
|
++s;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,9 +59,9 @@ TcpSocket::~TcpSocket()
|
||||||
#else
|
#else
|
||||||
::close(_sock);
|
::close(_sock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_outbuf)
|
if (_outbuf)
|
||||||
::free(_outbuf);
|
::free(_outbuf);
|
||||||
|
//printf("!!! TCP SOCKET DESTROYED @%.16llx to %s\r\n",(unsigned long long)this,_remote.toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TcpSocket::send(const InetAddress &to,const void *msg,unsigned int msglen)
|
bool TcpSocket::send(const InetAddress &to,const void *msg,unsigned int msglen)
|
||||||
|
|
|
@ -83,7 +83,10 @@ protected:
|
||||||
_outbufsize(0),
|
_outbufsize(0),
|
||||||
_inptr(0),
|
_inptr(0),
|
||||||
_connecting(c),
|
_connecting(c),
|
||||||
_remote(r) {}
|
_remote(r)
|
||||||
|
{
|
||||||
|
//printf("!!! TCP SOCKET CREATED @%.16llx to %s\r\n",(unsigned long long)this,_remote.toString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool notifyAvailableForRead(const SharedPtr<Socket> &self,SocketManager *sm);
|
virtual bool notifyAvailableForRead(const SharedPtr<Socket> &self,SocketManager *sm);
|
||||||
virtual bool notifyAvailableForWrite(const SharedPtr<Socket> &self,SocketManager *sm);
|
virtual bool notifyAvailableForWrite(const SharedPtr<Socket> &self,SocketManager *sm);
|
||||||
|
|
Loading…
Add table
Reference in a new issue