mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 10:04:33 +00:00
Logic error in the queueing of work ended up generating more stale blocks.
There is a small chance that a longpoll is signalled right at the start which would lead to a deadlock so check for first work before restart.
This commit is contained in:
parent
594b38b8cb
commit
9f726400d4
35
cpu-miner.c
35
cpu-miner.c
@ -728,7 +728,6 @@ static bool get_work(struct work *work)
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
get_new:
|
|
||||||
if (unlikely(!queue_request()))
|
if (unlikely(!queue_request()))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -737,24 +736,6 @@ get_new:
|
|||||||
if (unlikely(!work_heap))
|
if (unlikely(!work_heap))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (unlikely(work_restart[opt_n_threads + gpu_threads].restart)) {
|
|
||||||
work_restart[opt_n_threads + gpu_threads].restart = 0;
|
|
||||||
free(work_heap);
|
|
||||||
if (opt_debug)
|
|
||||||
applog(LOG_DEBUG, "New block detected, discarding old work");
|
|
||||||
for (i = 1; i < opt_queue; i++) {
|
|
||||||
/* Pop off all the work. Cancelling the requests would
|
|
||||||
* be better but tricky. */
|
|
||||||
work_heap = tq_pop(thr->q, NULL);
|
|
||||||
if (unlikely(!work_heap))
|
|
||||||
goto out;
|
|
||||||
free(work_heap);
|
|
||||||
if (unlikely(!queue_request()))
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
goto get_new;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(first_work)) {
|
if (unlikely(first_work)) {
|
||||||
first_work = false;
|
first_work = false;
|
||||||
/* send for extra work requests for the next time get_work
|
/* send for extra work requests for the next time get_work
|
||||||
@ -765,6 +746,22 @@ get_new:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unlikely(work_restart[opt_n_threads + gpu_threads].restart)) {
|
||||||
|
work_restart[opt_n_threads + gpu_threads].restart = 0;
|
||||||
|
if (opt_debug)
|
||||||
|
applog(LOG_DEBUG, "New block detected, discarding old work");
|
||||||
|
for (i = 1; i < opt_queue; i++) {
|
||||||
|
free(work_heap);
|
||||||
|
if (unlikely(!queue_request()))
|
||||||
|
goto out;
|
||||||
|
/* Pop off all the work. Cancelling the requests would
|
||||||
|
* be better but tricky. */
|
||||||
|
work_heap = tq_pop(thr->q, NULL);
|
||||||
|
if (unlikely(!work_heap))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(work, work_heap, sizeof(*work));
|
memcpy(work, work_heap, sizeof(*work));
|
||||||
memcpy(current_block, work->data, 36);
|
memcpy(current_block, work->data, 36);
|
||||||
ret = true;
|
ret = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user