Mercurial > hg > bitcoin
changeset 3353:6c7144e4c4ca draft
Merge pull request #1694 from sipa/fix_netloops
Fix infinite loops in connection logic
author | Gregory Maxwell <greg@xiph.org> |
---|---|
date | Wed, 22 Aug 2012 07:15:03 -0700 |
parents | ddf9fdb7e9b3 (current diff) e75b2db2a302 (diff) |
children | 018c947495d2 |
files | |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/init.cpp +++ b/src/init.cpp @@ -357,7 +357,7 @@ SoftSetBoolArg("-listen", true); } - if (mapArgs.count("-connect")) { + if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default SoftSetBoolArg("-dnsseed", false); SoftSetBoolArg("-listen", false);
--- a/src/net.cpp +++ b/src/net.cpp @@ -1391,7 +1391,7 @@ printf("ThreadOpenConnections started\n"); // Connect to specific addresses - if (mapArgs.count("-connect")) + if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { for (int64 nLoop = 0;; nLoop++) { @@ -1407,6 +1407,7 @@ return; } } + Sleep(500); } } @@ -1480,7 +1481,12 @@ if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr)) break; + // If we didn't find an appropriate destination after trying 100 addresses fetched from addrman, + // stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates + // already-connected network ranges, ...) before trying new addrman addresses. nTries++; + if (nTries > 100) + break; if (IsLimited(addr)) continue;