From 69a942b4e9cb67266b448304f2cad522007e34bf Mon Sep 17 00:00:00 2001 From: Roman Mindalev Date: Fri, 9 Aug 2013 12:28:52 +0400 Subject: [PATCH] Crawler thread should know amount of threads for correct sleep --- main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 03d9674..2e88ed4 100644 --- a/main.cpp +++ b/main.cpp @@ -11,8 +11,6 @@ #include "bitcoin.h" #include "db.h" -#define NTHREADS 24 - using namespace std; bool fTestNet = false; @@ -126,6 +124,7 @@ extern "C" { CAddrDb db; extern "C" void* ThreadCrawler(void* data) { + int *nThreads=(int*)data; do { std::vector ips; int wait = 5; @@ -133,7 +132,7 @@ extern "C" void* ThreadCrawler(void* data) { int64 now = time(NULL); if (ips.empty()) { wait *= 1000; - wait += rand() % (500 * NTHREADS); + wait += rand() % (500 * *nThreads); Sleep(wait); continue; } @@ -422,7 +421,7 @@ int main(int argc, char **argv) { pthread_attr_setstacksize(&attr_crawler, 0x20000); for (int i=0; i