mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Avoid applog under pool_lock.
This commit is contained in:
parent
51fbcfed6d
commit
3209c113d1
13
cgminer.c
13
cgminer.c
@ -2935,7 +2935,6 @@ static void recruit_curl(struct pool *pool)
|
|||||||
|
|
||||||
list_add(&ce->node, &pool->curlring);
|
list_add(&ce->node, &pool->curlring);
|
||||||
pool->curls++;
|
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
|
/* 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)
|
static struct curl_ent *pop_curl_entry(struct pool *pool)
|
||||||
{
|
{
|
||||||
int curl_limit = opt_delaynet ? 5 : (mining_threads + opt_queue) * 2;
|
int curl_limit = opt_delaynet ? 5 : (mining_threads + opt_queue) * 2;
|
||||||
|
bool recruited = false;
|
||||||
struct curl_ent *ce;
|
struct curl_ent *ce;
|
||||||
|
|
||||||
mutex_lock(&pool->pool_lock);
|
mutex_lock(&pool->pool_lock);
|
||||||
retry:
|
retry:
|
||||||
if (!pool->curls)
|
if (!pool->curls) {
|
||||||
recruit_curl(pool);
|
recruit_curl(pool);
|
||||||
else if (list_empty(&pool->curlring)) {
|
recruited = true;
|
||||||
|
} else if (list_empty(&pool->curlring)) {
|
||||||
if (pool->curls >= curl_limit) {
|
if (pool->curls >= curl_limit) {
|
||||||
pthread_cond_wait(&pool->cr_cond, &pool->pool_lock);
|
pthread_cond_wait(&pool->cr_cond, &pool->pool_lock);
|
||||||
goto retry;
|
goto retry;
|
||||||
} else
|
} else {
|
||||||
recruit_curl(pool);
|
recruit_curl(pool);
|
||||||
|
recruited = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ce = list_entry(pool->curlring.next, struct curl_ent, node);
|
ce = list_entry(pool->curlring.next, struct curl_ent, node);
|
||||||
list_del(&ce->node);
|
list_del(&ce->node);
|
||||||
mutex_unlock(&pool->pool_lock);
|
mutex_unlock(&pool->pool_lock);
|
||||||
|
|
||||||
|
if (recruited)
|
||||||
|
applog(LOG_DEBUG, "Recruited curl for pool %d", pool->pool_no);
|
||||||
return ce;
|
return ce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user