Fix a DNS bug in Csocket with non-blocking resolvers

After the first attempt to lookup an address, Csocket already created the socket
used for communicating. Since at this point it wasn't yet known whether we will
yield a IPv4 or IPv6 address, Csocket just always used IPv4. This would then
later fail to connect() with 'Address family not supported by protocol'.

This patch fixes this by creating the socket fd only when the DNS lookup
completed successfully.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1556 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-07-04 12:54:15 +00:00
parent 79a80cefb2
commit 4c14b1bf61
+6 -3
View File
@@ -2051,11 +2051,14 @@ int Csock::DNSLookup( EDNSLType eDNSLType )
iRet = GetAddrInfo( m_shostname, m_address );
}
if( !CreateSocksFD() )
iRet = ETIMEDOUT;
if ( iRet == 0 )
{
if( !CreateSocksFD() )
{
m_iDNSTryCount = 0;
return ETIMEDOUT;
}
if ( m_eConState != CST_OK )
m_eConState = ( ( eDNSLType == DNS_VHOST ) ? CST_BINDVHOST : CST_CONNECT );
m_iDNSTryCount = 0;