Avoid applog under pool_lock.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/cgminer.c b/cgminer.c
index 23e5bd9..3eeaa40 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;
}