diff options
| author | Pieter Wuille <[email protected]> | 2012-08-21 17:32:04 +0200 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2012-08-22 13:35:33 +0200 |
| commit | f161a2c2114cd7d950248ce75a91ba1923e9abb1 (patch) | |
| tree | c0a36b5585a4d8b490324e8c3dc575d3cee146da /src/net.cpp | |
| parent | Merge branch 'testdata' of git://github.com/TheBlueMatt/bitcoin (diff) | |
| download | discoin-f161a2c2114cd7d950248ce75a91ba1923e9abb1.tar.xz discoin-f161a2c2114cd7d950248ce75a91ba1923e9abb1.zip | |
Fix infinite loops in connection logic
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/net.cpp b/src/net.cpp index 1c87eb968..aaf7883e5 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1391,7 +1391,7 @@ void ThreadOpenConnections2(void* parg) 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 @@ void ThreadOpenConnections2(void* parg) return; } } + Sleep(500); } } @@ -1480,7 +1481,12 @@ void ThreadOpenConnections2(void* parg) 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; |