From 3209c113d1cca200a393c8dbfaee81d4c404362c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 15 Apr 2013 11:34:21 +1000 Subject: [PATCH] Avoid applog under pool_lock. --- cgminer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cgminer.c b/cgminer.c index 23e5bd95..3eeaa40d 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2935,7 +2935,6 @@ static void recruit_curl(struct pool *pool) list_add(&ce->node, &pool->curlring); pool->curls++; - applog(LOG_DEBUG, "Recruited curl %d for pool %d", pool->curls, pool->pool_no); } /* Grab an available curl if there is one. If not, then recruit extra curls @@ -2946,23 +2945,29 @@ static void recruit_curl(struct pool *pool) static struct curl_ent *pop_curl_entry(struct pool *pool) { int curl_limit = opt_delaynet ? 5 : (mining_threads + opt_queue) * 2; + bool recruited = false; struct curl_ent *ce; mutex_lock(&pool->pool_lock); retry: - if (!pool->curls) + if (!pool->curls) { recruit_curl(pool); - else if (list_empty(&pool->curlring)) { + recruited = true; + } else if (list_empty(&pool->curlring)) { if (pool->curls >= curl_limit) { pthread_cond_wait(&pool->cr_cond, &pool->pool_lock); goto retry; - } else + } else { recruit_curl(pool); + recruited = true; + } } ce = list_entry(pool->curlring.next, struct curl_ent, node); list_del(&ce->node); mutex_unlock(&pool->pool_lock); + if (recruited) + applog(LOG_DEBUG, "Recruited curl for pool %d", pool->pool_no); return ce; }