mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-23 04:54:26 +00:00
Make sure we have work from the current pool somewhere in the queue in case the queue is full of requests from a pool that has just died.
This commit is contained in:
parent
c0aaf56a8d
commit
8aa61f6626
29
cgminer.c
29
cgminer.c
@ -2238,16 +2238,30 @@ static void __inc_queued(void)
|
|||||||
total_queued++;
|
total_queued++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __dec_queued(void)
|
static int __pool_pending_staged(struct pool *pool)
|
||||||
|
{
|
||||||
|
return pool->queued + pool->staged;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void inc_pool_queued(struct pool *pool)
|
||||||
|
{
|
||||||
|
mutex_lock(stgd_lock);
|
||||||
|
pool->queued++;
|
||||||
|
mutex_unlock(stgd_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __dec_queued(struct pool *pool)
|
||||||
{
|
{
|
||||||
if (total_queued)
|
if (total_queued)
|
||||||
total_queued--;
|
total_queued--;
|
||||||
|
if (pool && pool->queued)
|
||||||
|
pool->queued--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dec_queued(void)
|
static void dec_queued(void)
|
||||||
{
|
{
|
||||||
mutex_lock(stgd_lock);
|
mutex_lock(stgd_lock);
|
||||||
__dec_queued();
|
__dec_queued(NULL);
|
||||||
mutex_unlock(stgd_lock);
|
mutex_unlock(stgd_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2290,6 +2304,7 @@ static void *get_work_thread(void *userdata)
|
|||||||
else {
|
else {
|
||||||
pool = ret_work->pool = select_pool(wc->lagging);
|
pool = ret_work->pool = select_pool(wc->lagging);
|
||||||
ce = pop_curl_entry(pool);
|
ce = pop_curl_entry(pool);
|
||||||
|
inc_pool_queued(pool);
|
||||||
|
|
||||||
/* obtain new work from bitcoin via JSON-RPC */
|
/* obtain new work from bitcoin via JSON-RPC */
|
||||||
while (!get_upstream_work(ret_work, ce->curl)) {
|
while (!get_upstream_work(ret_work, ce->curl)) {
|
||||||
@ -2762,7 +2777,8 @@ static bool hash_push(struct work *work)
|
|||||||
mutex_lock(stgd_lock);
|
mutex_lock(stgd_lock);
|
||||||
if (likely(!getq->frozen)) {
|
if (likely(!getq->frozen)) {
|
||||||
HASH_ADD_INT(staged_work, id, work);
|
HASH_ADD_INT(staged_work, id, work);
|
||||||
__dec_queued();
|
work->pool->staged++;
|
||||||
|
__dec_queued(work->pool);
|
||||||
HASH_SORT(staged_work, tv_sort);
|
HASH_SORT(staged_work, tv_sort);
|
||||||
} else
|
} else
|
||||||
rc = false;
|
rc = false;
|
||||||
@ -3795,9 +3811,10 @@ static bool clone_available(void)
|
|||||||
|
|
||||||
bool queue_request(struct thr_info *thr, bool needed)
|
bool queue_request(struct thr_info *thr, bool needed)
|
||||||
{
|
{
|
||||||
|
struct pool *cp = current_pool();
|
||||||
struct workio_cmd *wc;
|
struct workio_cmd *wc;
|
||||||
|
int ps, ts, maxq, pps;
|
||||||
bool lag, ret, qing;
|
bool lag, ret, qing;
|
||||||
int ps, ts, maxq;
|
|
||||||
|
|
||||||
maxq = opt_queue + mining_threads;
|
maxq = opt_queue + mining_threads;
|
||||||
lag = ret = qing = false;
|
lag = ret = qing = false;
|
||||||
@ -3806,9 +3823,10 @@ bool queue_request(struct thr_info *thr, bool needed)
|
|||||||
__inc_queued();
|
__inc_queued();
|
||||||
ps = __pending_staged();
|
ps = __pending_staged();
|
||||||
ts = __total_staged();
|
ts = __total_staged();
|
||||||
|
pps = __pool_pending_staged(cp);
|
||||||
mutex_unlock(stgd_lock);
|
mutex_unlock(stgd_lock);
|
||||||
|
|
||||||
if (ps >= maxq) {
|
if (pps && ps >= maxq) {
|
||||||
ret = true;
|
ret = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -3860,6 +3878,7 @@ static struct work *hash_pop(const struct timespec *abstime)
|
|||||||
if (worka->clone) {
|
if (worka->clone) {
|
||||||
HASH_DEL(staged_work, worka);
|
HASH_DEL(staged_work, worka);
|
||||||
work = worka;
|
work = worka;
|
||||||
|
work->pool->staged--;
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user