@ -367,7 +367,7 @@ CNode* FindNode(const CService& addr)
return NULL ;
return NULL ;
}
}
CNode * ConnectNode ( CAddress addrConnect , const char * pszDest )
CNode * ConnectNode ( CAddress addrConnect , const char * pszDest , bool fCountFailure )
{
{
if ( pszDest = = NULL ) {
if ( pszDest = = NULL ) {
if ( IsLocal ( addrConnect ) )
if ( IsLocal ( addrConnect ) )
@ -399,7 +399,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
return NULL ;
return NULL ;
}
}
addrman . Attempt ( addrConnect ) ;
addrman . Attempt ( addrConnect , fCountFailure ) ;
// Add node
// Add node
CNode * pnode = new CNode ( hSocket , addrConnect , pszDest ? pszDest : " " , false ) ;
CNode * pnode = new CNode ( hSocket , addrConnect , pszDest ? pszDest : " " , false ) ;
@ -416,7 +416,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
} else if ( ! proxyConnectionFailed ) {
} else if ( ! proxyConnectionFailed ) {
// If connecting to the node failed, and failure is not caused by a problem connecting to
// If connecting to the node failed, and failure is not caused by a problem connecting to
// the proxy, mark this as an attempt.
// the proxy, mark this as an attempt.
addrman . Attempt ( addrConnect ) ;
addrman . Attempt ( addrConnect , fCountFailure ) ;
}
}
return NULL ;
return NULL ;
@ -1533,7 +1533,7 @@ void static ProcessOneShot()
CAddress addr ;
CAddress addr ;
CSemaphoreGrant grant ( * semOutbound , true ) ;
CSemaphoreGrant grant ( * semOutbound , true ) ;
if ( grant ) {
if ( grant ) {
if ( ! OpenNetworkConnection ( addr , & grant , strDest . c_str ( ) , true ) )
if ( ! OpenNetworkConnection ( addr , false , & grant , strDest . c_str ( ) , true ) )
AddOneShot ( strDest ) ;
AddOneShot ( strDest ) ;
}
}
}
}
@ -1549,7 +1549,7 @@ void ThreadOpenConnections()
BOOST_FOREACH ( const std : : string & strAddr , mapMultiArgs [ " -connect " ] )
BOOST_FOREACH ( const std : : string & strAddr , mapMultiArgs [ " -connect " ] )
{
{
CAddress addr ;
CAddress addr ;
OpenNetworkConnection ( addr , NULL , strAddr . c_str ( ) ) ;
OpenNetworkConnection ( addr , false , NULL , strAddr . c_str ( ) ) ;
for ( int i = 0 ; i < 10 & & i < nLoop ; i + + )
for ( int i = 0 ; i < 10 & & i < nLoop ; i + + )
{
{
MilliSleep ( 500 ) ;
MilliSleep ( 500 ) ;
@ -1633,7 +1633,7 @@ void ThreadOpenConnections()
}
}
if ( addrConnect . IsValid ( ) )
if ( addrConnect . IsValid ( ) )
OpenNetworkConnection ( addrConnect , & grant ) ;
OpenNetworkConnection ( addrConnect , ( int ) setConnected . size ( ) > = min ( nMaxConnections - 1 , 2 ) , & grant ) ;
}
}
}
}
@ -1655,7 +1655,7 @@ void ThreadOpenAddedConnections()
BOOST_FOREACH ( const std : : string & strAddNode , lAddresses ) {
BOOST_FOREACH ( const std : : string & strAddNode , lAddresses ) {
CAddress addr ;
CAddress addr ;
CSemaphoreGrant grant ( * semOutbound ) ;
CSemaphoreGrant grant ( * semOutbound ) ;
OpenNetworkConnection ( addr , & grant , strAddNode . c_str ( ) ) ;
OpenNetworkConnection ( addr , false , & grant , strAddNode . c_str ( ) ) ;
MilliSleep ( 500 ) ;
MilliSleep ( 500 ) ;
}
}
MilliSleep ( 120000 ) ; // Retry every 2 minutes
MilliSleep ( 120000 ) ; // Retry every 2 minutes
@ -1694,7 +1694,7 @@ void ThreadOpenAddedConnections()
BOOST_FOREACH ( std : : vector < CService > & vserv , lservAddressesToAdd )
BOOST_FOREACH ( std : : vector < CService > & vserv , lservAddressesToAdd )
{
{
CSemaphoreGrant grant ( * semOutbound ) ;
CSemaphoreGrant grant ( * semOutbound ) ;
OpenNetworkConnection ( CAddress ( vserv [ i % vserv . size ( ) ] ) , & grant ) ;
OpenNetworkConnection ( CAddress ( vserv [ i % vserv . size ( ) ] ) , false , & grant ) ;
MilliSleep ( 500 ) ;
MilliSleep ( 500 ) ;
}
}
MilliSleep ( 120000 ) ; // Retry every 2 minutes
MilliSleep ( 120000 ) ; // Retry every 2 minutes
@ -1702,7 +1702,7 @@ void ThreadOpenAddedConnections()
}
}
// if successful, this moves the passed grant to the constructed node
// if successful, this moves the passed grant to the constructed node
bool OpenNetworkConnection ( const CAddress & addrConnect , CSemaphoreGrant * grantOutbound , const char * pszDest , bool fOneShot )
bool OpenNetworkConnection ( const CAddress & addrConnect , bool fCountFailure , CSemaphoreGrant * grantOutbound , const char * pszDest , bool fOneShot )
{
{
//
//
// Initiate outbound network connection
// Initiate outbound network connection
@ -1716,7 +1716,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
} else if ( FindNode ( std : : string ( pszDest ) ) )
} else if ( FindNode ( std : : string ( pszDest ) ) )
return false ;
return false ;
CNode * pnode = ConnectNode ( addrConnect , pszDest ) ;
CNode * pnode = ConnectNode ( addrConnect , pszDest , fCountFailure ) ;
boost : : this_thread : : interruption_point ( ) ;
boost : : this_thread : : interruption_point ( ) ;
if ( ! pnode )
if ( ! pnode )