mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Invalidating work after longpoll made hash_pop return no work giving a false positive for dead pool.
Rework hash_pop to retry while finds no staged work until the abstime timeout really expires.
This commit is contained in:
parent
4cf433c917
commit
12afb479d3
28
main.c
28
main.c
@ -4087,31 +4087,23 @@ static bool queue_request(struct thr_info *thr, bool needed)
|
||||
return true;
|
||||
}
|
||||
|
||||
struct work *hash_pop(const struct timespec *abstime)
|
||||
static struct work *hash_pop(const struct timespec *abstime)
|
||||
{
|
||||
struct work *work = NULL;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
mutex_lock(stgd_lock);
|
||||
if (HASH_COUNT(staged_work))
|
||||
goto pop;
|
||||
|
||||
if (abstime)
|
||||
while (!getq->frozen && !HASH_COUNT(staged_work) && !rc)
|
||||
rc = pthread_cond_timedwait(&getq->cond, stgd_lock, abstime);
|
||||
else
|
||||
rc = pthread_cond_wait(&getq->cond, stgd_lock);
|
||||
if (rc)
|
||||
goto out;
|
||||
if (!HASH_COUNT(staged_work))
|
||||
goto out;
|
||||
|
||||
pop:
|
||||
work = staged_work;
|
||||
HASH_DEL(staged_work, work);
|
||||
if (work->clone)
|
||||
--staged_clones;
|
||||
out:
|
||||
if (HASH_COUNT(staged_work)) {
|
||||
work = staged_work;
|
||||
HASH_DEL(staged_work, work);
|
||||
if (work->clone)
|
||||
--staged_clones;
|
||||
}
|
||||
mutex_unlock(stgd_lock);
|
||||
|
||||
return work;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user