|
|
|
@ -2935,7 +2935,6 @@ static void recruit_curl(struct pool *pool)
@@ -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)
@@ -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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|