From 7458d091664bb488dab3eac22966f176ed5d7640 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 20 Dec 2015 21:37:57 -0200 Subject: [PATCH] addrman corruption causes infinite-loop and twisterd shutdown hangs. try to fix this. --- src/addrman.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 296e1909..52b88165 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -405,7 +405,8 @@ CAddress CAddrMan::Select_(int nUnkBias) { // use a tried node double fChanceFactor = 1.0; - while(1) + int retries = 10000; + while(retries--) { int nKBucket = GetRandInt(vvTried.size()); std::vector &vTried = vvTried[nKBucket]; @@ -417,10 +418,19 @@ CAddress CAddrMan::Select_(int nUnkBias) return info; fChanceFactor *= 1.2; } + + // inconsistency?? try recounting nTried to fix it + printf("CAddrMan::Select_ nTried inconsistency - fixing\n"); + nTried = 0; + for (int n=0; n &vNew = vvNew[nUBucket]; @@ -435,6 +445,14 @@ CAddress CAddrMan::Select_(int nUnkBias) return info; fChanceFactor *= 1.2; } + + // inconsistency?? try recounting nNew to fix it + printf("CAddrMan::Select_ nNew inconsistency - fixing\n"); + nNew = 0; + for (int n=0; n