|
|
@@ -499,6 +499,7 @@ struct pool *add_pool(void)
|
|
|
mutex_init(&pool->pool_lock);
|
|
|
if (unlikely(pthread_cond_init(&pool->cr_cond, NULL)))
|
|
|
quit(1, "Failed to pthread_cond_init in add_pool");
|
|
|
+ cglock_init(&pool->data_lock);
|
|
|
mutex_init(&pool->stratum_lock);
|
|
|
INIT_LIST_HEAD(&pool->curlring);
|
|
|
pool->swork.transparency_time = (time_t)-1;
|
|
|
@@ -3870,10 +3871,10 @@ bool stale_work(struct work *work, bool share)
|
|
|
}
|
|
|
|
|
|
same_job = true;
|
|
|
- mutex_lock(&pool->pool_lock);
|
|
|
+ cg_rlock(&pool->data_lock);
|
|
|
if (strcmp(work->job_id, pool->swork.job_id))
|
|
|
same_job = false;
|
|
|
- mutex_unlock(&pool->pool_lock);
|
|
|
+ cg_runlock(&pool->data_lock);
|
|
|
if (!same_job) {
|
|
|
applog(LOG_DEBUG, "Work stale due to stratum job_id mismatch");
|
|
|
return true;
|
|
|
@@ -4181,11 +4182,11 @@ static void *submit_work_thread(__maybe_unused void *userdata)
|
|
|
int fd = pool->sock;
|
|
|
bool sessionid_match;
|
|
|
|
|
|
- mutex_lock(&pool->pool_lock);
|
|
|
+ cg_rlock(&pool->data_lock);
|
|
|
// NOTE: cgminer only does this check on retries, but BFGMiner does it for even the first/normal submit; therefore, it needs to be such that it always is true on the same connection regardless of session management
|
|
|
// NOTE: Worst case scenario for a false positive: the pool rejects it as H-not-zero
|
|
|
sessionid_match = (!pool->nonce1) || !strcmp(work->nonce1, pool->nonce1);
|
|
|
- mutex_unlock(&pool->pool_lock);
|
|
|
+ cg_runlock(&pool->data_lock);
|
|
|
if (!sessionid_match)
|
|
|
{
|
|
|
applog(LOG_DEBUG, "No matching session id for resubmitting stratum share");
|
|
|
@@ -6186,9 +6187,9 @@ static bool supports_resume(struct pool *pool)
|
|
|
{
|
|
|
bool ret;
|
|
|
|
|
|
- mutex_lock(&pool->pool_lock);
|
|
|
+ cg_rlock(&pool->data_lock);
|
|
|
ret = (pool->sessionid != NULL);
|
|
|
- mutex_unlock(&pool->pool_lock);
|
|
|
+ cg_runlock(&pool->data_lock);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -6690,7 +6691,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
|
|
|
|
|
|
clean_work(work);
|
|
|
|
|
|
- mutex_lock(&pool->pool_lock);
|
|
|
+ cg_wlock(&pool->data_lock);
|
|
|
|
|
|
/* Generate coinbase */
|
|
|
work->nonce2 = bin2hex((const unsigned char *)&pool->nonce2, pool->n2size);
|
|
|
@@ -6743,7 +6744,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
|
|
|
work->job_id = strdup(pool->swork.job_id);
|
|
|
work->nonce1 = strdup(pool->nonce1);
|
|
|
work->ntime = strdup(pool->swork.ntime);
|
|
|
- mutex_unlock(&pool->pool_lock);
|
|
|
+ cg_wunlock(&pool->data_lock);
|
|
|
|
|
|
applog(LOG_DEBUG, "Generated stratum merkle %s", merkle_hash);
|
|
|
applog(LOG_DEBUG, "Generated stratum header %s", header);
|