|
|
@@ -421,6 +421,7 @@ struct thr_info *get_thread(int thr_id)
|
|
|
rd_lock(&mining_thr_lock);
|
|
|
thr = mining_thr[thr_id];
|
|
|
rd_unlock(&mining_thr_lock);
|
|
|
+
|
|
|
return thr;
|
|
|
}
|
|
|
|
|
|
@@ -438,6 +439,7 @@ struct cgpu_info *get_devices(int id)
|
|
|
rd_lock(&devices_lock);
|
|
|
cgpu = devices[id];
|
|
|
rd_unlock(&devices_lock);
|
|
|
+
|
|
|
return cgpu;
|
|
|
}
|
|
|
|
|
|
@@ -478,6 +480,7 @@ static void sharelog(const char*disposition, const struct work*work)
|
|
|
ret = fwrite(s, rv, 1, sharelog_file);
|
|
|
fflush(sharelog_file);
|
|
|
mutex_unlock(&sharelog_lock);
|
|
|
+
|
|
|
if (ret != 1)
|
|
|
applog(LOG_ERR, "sharelog fwrite error");
|
|
|
}
|
|
|
@@ -525,6 +528,7 @@ static bool pool_tset(struct pool *pool, bool *var)
|
|
|
ret = *var;
|
|
|
*var = true;
|
|
|
mutex_unlock(&pool->pool_lock);
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -536,6 +540,7 @@ bool pool_tclear(struct pool *pool, bool *var)
|
|
|
ret = *var;
|
|
|
*var = false;
|
|
|
mutex_unlock(&pool->pool_lock);
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -546,6 +551,7 @@ struct pool *current_pool(void)
|
|
|
cg_rlock(&control_lock);
|
|
|
pool = currentpool;
|
|
|
cg_runlock(&control_lock);
|
|
|
+
|
|
|
return pool;
|
|
|
}
|
|
|
|
|
|
@@ -1791,9 +1797,11 @@ static struct work *make_work(void)
|
|
|
|
|
|
if (unlikely(!work))
|
|
|
quit(1, "Failed to calloc work in make_work");
|
|
|
+
|
|
|
cg_wlock(&control_lock);
|
|
|
work->id = total_work++;
|
|
|
cg_wunlock(&control_lock);
|
|
|
+
|
|
|
return work;
|
|
|
}
|
|
|
|
|
|
@@ -2056,6 +2064,7 @@ static int total_staged(void)
|
|
|
mutex_lock(stgd_lock);
|
|
|
ret = __total_staged();
|
|
|
mutex_unlock(stgd_lock);
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -3839,10 +3848,12 @@ bool stale_work(struct work *work, bool share)
|
|
|
}
|
|
|
|
|
|
same_job = true;
|
|
|
+
|
|
|
cg_rlock(&pool->data_lock);
|
|
|
if (strcmp(work->job_id, pool->swork.job_id))
|
|
|
same_job = false;
|
|
|
cg_runlock(&pool->data_lock);
|
|
|
+
|
|
|
if (!same_job) {
|
|
|
applog(LOG_DEBUG, "Work stale due to stratum job_id mismatch");
|
|
|
return true;
|
|
|
@@ -3882,6 +3893,7 @@ static uint64_t share_diff(const struct work *work)
|
|
|
bool new_best = false;
|
|
|
|
|
|
ret = target_diff(work->hash);
|
|
|
+
|
|
|
cg_wlock(&control_lock);
|
|
|
if (unlikely(ret > best_diff)) {
|
|
|
new_best = true;
|
|
|
@@ -4622,6 +4634,7 @@ static bool block_exists(char *hexstr)
|
|
|
rd_lock(&blk_lock);
|
|
|
HASH_FIND_STR(blocks, hexstr, s);
|
|
|
rd_unlock(&blk_lock);
|
|
|
+
|
|
|
if (s)
|
|
|
return true;
|
|
|
return false;
|
|
|
@@ -4686,6 +4699,7 @@ static bool test_work_current(struct work *work)
|
|
|
quit (1, "test_work_current OOM");
|
|
|
strcpy(s->hash, hexstr);
|
|
|
s->block_no = new_blocks++;
|
|
|
+
|
|
|
wr_lock(&blk_lock);
|
|
|
/* Only keep the last hour's worth of blocks in memory since
|
|
|
* work from blocks before this is virtually impossible and we
|
|
|
@@ -4703,6 +4717,7 @@ static bool test_work_current(struct work *work)
|
|
|
set_blockdiff(work);
|
|
|
wr_unlock(&blk_lock);
|
|
|
work->pool->block_id = block_id;
|
|
|
+
|
|
|
if (deleted_block)
|
|
|
applog(LOG_DEBUG, "Deleted block %d from database", deleted_block);
|
|
|
template_nonce = 0;
|
|
|
@@ -5886,6 +5901,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
|
|
|
local_mhashes_done = 0;
|
|
|
out_unlock:
|
|
|
mutex_unlock(&hash_lock);
|
|
|
+
|
|
|
if (showlog) {
|
|
|
if (!curses_active) {
|
|
|
printf("%s \r", statusline);
|
|
|
@@ -5988,11 +6004,13 @@ fishy:
|
|
|
}
|
|
|
|
|
|
id = json_integer_value(id_val);
|
|
|
+
|
|
|
mutex_lock(&sshare_lock);
|
|
|
HASH_FIND_INT(stratum_shares, &id, sshare);
|
|
|
if (sshare)
|
|
|
HASH_DEL(stratum_shares, sshare);
|
|
|
mutex_unlock(&sshare_lock);
|
|
|
+
|
|
|
if (!sshare) {
|
|
|
if (json_is_true(res_val))
|
|
|
applog(LOG_NOTICE, "Accepted untracked stratum share from pool %d", pool->pool_no);
|
|
|
@@ -6120,6 +6138,7 @@ static int cp_prio(void)
|
|
|
cg_rlock(&control_lock);
|
|
|
prio = currentpool->prio;
|
|
|
cg_runlock(&control_lock);
|
|
|
+
|
|
|
return prio;
|
|
|
}
|
|
|
|
|
|
@@ -6185,6 +6204,7 @@ static bool supports_resume(struct pool *pool)
|
|
|
cg_rlock(&pool->data_lock);
|
|
|
ret = (pool->sessionid != NULL);
|
|
|
cg_runlock(&pool->data_lock);
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -7090,6 +7110,7 @@ void work_completed(struct cgpu_info *cgpu, struct work *work)
|
|
|
cgpu->queued_count--;
|
|
|
HASH_DEL(cgpu->queued_work, work);
|
|
|
wr_unlock(&cgpu->qlock);
|
|
|
+
|
|
|
free_work(work);
|
|
|
}
|
|
|
|
|
|
@@ -7465,6 +7486,7 @@ static void reap_curl(struct pool *pool)
|
|
|
int reaped = 0;
|
|
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
+
|
|
|
mutex_lock(&pool->pool_lock);
|
|
|
list_for_each_entry_safe(ent, iter, &pool->curlring, node) {
|
|
|
if (pool->curls < 2)
|
|
|
@@ -7478,6 +7500,7 @@ static void reap_curl(struct pool *pool)
|
|
|
}
|
|
|
}
|
|
|
mutex_unlock(&pool->pool_lock);
|
|
|
+
|
|
|
if (reaped)
|
|
|
applog(LOG_DEBUG, "Reaped %d curl%s from pool %d", reaped, reaped > 1 ? "s" : "", pool->pool_no);
|
|
|
}
|
|
|
@@ -7621,6 +7644,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
|
|
|
applog(LOG_WARNING, "Will restart execution as scheduled at %02d:%02d",
|
|
|
schedstart.tm.tm_hour, schedstart.tm.tm_min);
|
|
|
sched_paused = true;
|
|
|
+
|
|
|
rd_lock(&mining_thr_lock);
|
|
|
for (i = 0; i < mining_threads; i++)
|
|
|
mining_thr[i]->pause = true;
|
|
|
@@ -7970,6 +7994,7 @@ static void *test_pool_thread(void *arg)
|
|
|
pools_active = true;
|
|
|
}
|
|
|
cg_wunlock(&control_lock);
|
|
|
+
|
|
|
pool_resus(pool);
|
|
|
} else
|
|
|
pool_died(pool);
|
|
|
@@ -8195,9 +8220,11 @@ static int device_line_id_count;
|
|
|
void register_device(struct cgpu_info *cgpu)
|
|
|
{
|
|
|
cgpu->deven = DEV_ENABLED;
|
|
|
+
|
|
|
wr_lock(&devices_lock);
|
|
|
devices[cgpu->cgminer_id = cgminer_id_count++] = cgpu;
|
|
|
wr_unlock(&devices_lock);
|
|
|
+
|
|
|
if (!cgpu->proc_id)
|
|
|
cgpu->device_line_id = device_line_id_count++;
|
|
|
mining_threads += cgpu->threads ?: 1;
|