Browse Source

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.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
8aa61f6626
  1. 29
      cgminer.c
  2. 2
      miner.h

29
cgminer.c

@ -2238,16 +2238,30 @@ static void __inc_queued(void) @@ -2238,16 +2238,30 @@ static void __inc_queued(void)
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)
total_queued--;
if (pool && pool->queued)
pool->queued--;
}
static void dec_queued(void)
{
mutex_lock(stgd_lock);
__dec_queued();
__dec_queued(NULL);
mutex_unlock(stgd_lock);
}
@ -2290,6 +2304,7 @@ static void *get_work_thread(void *userdata) @@ -2290,6 +2304,7 @@ static void *get_work_thread(void *userdata)
else {
pool = ret_work->pool = select_pool(wc->lagging);
ce = pop_curl_entry(pool);
inc_pool_queued(pool);
/* obtain new work from bitcoin via JSON-RPC */
while (!get_upstream_work(ret_work, ce->curl)) {
@ -2762,7 +2777,8 @@ static bool hash_push(struct work *work) @@ -2762,7 +2777,8 @@ static bool hash_push(struct work *work)
mutex_lock(stgd_lock);
if (likely(!getq->frozen)) {
HASH_ADD_INT(staged_work, id, work);
__dec_queued();
work->pool->staged++;
__dec_queued(work->pool);
HASH_SORT(staged_work, tv_sort);
} else
rc = false;
@ -3795,9 +3811,10 @@ static bool clone_available(void) @@ -3795,9 +3811,10 @@ static bool clone_available(void)
bool queue_request(struct thr_info *thr, bool needed)
{
struct pool *cp = current_pool();
struct workio_cmd *wc;
int ps, ts, maxq, pps;
bool lag, ret, qing;
int ps, ts, maxq;
maxq = opt_queue + mining_threads;
lag = ret = qing = false;
@ -3806,9 +3823,10 @@ bool queue_request(struct thr_info *thr, bool needed) @@ -3806,9 +3823,10 @@ bool queue_request(struct thr_info *thr, bool needed)
__inc_queued();
ps = __pending_staged();
ts = __total_staged();
pps = __pool_pending_staged(cp);
mutex_unlock(stgd_lock);
if (ps >= maxq) {
if (pps && ps >= maxq) {
ret = true;
goto out;
}
@ -3860,6 +3878,7 @@ static struct work *hash_pop(const struct timespec *abstime) @@ -3860,6 +3878,7 @@ static struct work *hash_pop(const struct timespec *abstime)
if (worka->clone) {
HASH_DEL(staged_work, worka);
work = worka;
work->pool->staged--;
goto out_unlock;
}
}

2
miner.h

@ -720,6 +720,8 @@ struct pool { @@ -720,6 +720,8 @@ struct pool {
int accepted, rejected;
int seq_rejects;
int solved;
int queued;
int staged;
bool submit_fail;
bool idle;

Loading…
Cancel
Save