From b40c8b848f370fbec4ef2b77b1369253129f0b89 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 29 Jul 2012 19:10:40 +1000 Subject: [PATCH] Limit total number of curls recruited per pool to the number of mining threads to prevent blasting the network when we only have one pool to talk to. --- cgminer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cgminer.c b/cgminer.c index 28a1b104..4c5b5da5 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2140,16 +2140,19 @@ static void recruit_curl(struct pool *pool) /* Grab an available curl if there is one. If not, then recruit extra curls * unless we are in a submit_fail situation, or we have opt_delaynet enabled - * and there are already 5 curls in circulation */ + * and there are already 5 curls in circulation. Limit total number to the + * number of mining threads per pool as well to prevent blasting a pool during + * network delays/outages. */ static struct curl_ent *pop_curl_entry(struct pool *pool) { + int curl_limit = opt_delaynet ? 5 : mining_threads; struct curl_ent *ce; mutex_lock(&pool->pool_lock); if (!pool->curls) recruit_curl(pool); else if (list_empty(&pool->curlring)) { - if ((pool->submit_fail || opt_delaynet) && pool->curls > 4) + if (pool->curls >= curl_limit) pthread_cond_wait(&pool->cr_cond, &pool->pool_lock); else recruit_curl(pool);