Overlap queued decrementing with staged incrementing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/cgminer.c b/cgminer.c
index 827e217..6f500f0 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2427,7 +2427,7 @@ static void *get_work_thread(void *userdata)
}
fail_pause = opt_fail_pause;
- dec_queued(pool);
+ ret_work->queued = true;
}
applog(LOG_DEBUG, "Pushing work to requesting thread");
@@ -2890,7 +2890,12 @@ static int tv_sort(struct work *worka, struct work *workb)
static bool hash_push(struct work *work)
{
- bool rc = true;
+ bool rc = true, dec = false;
+
+ if (work->queued) {
+ work->queued = false;
+ dec = true;
+ }
mutex_lock(stgd_lock);
if (likely(!getq->frozen)) {
@@ -2901,6 +2906,10 @@ static bool hash_push(struct work *work)
rc = false;
pthread_cond_signal(&getq->cond);
mutex_unlock(stgd_lock);
+
+ if (dec)
+ dec_queued(work->pool);
+
return rc;
}
diff --git a/miner.h b/miner.h
index f87612a..d79578e 100644
--- a/miner.h
+++ b/miner.h
@@ -795,6 +795,7 @@ struct work {
bool stale;
bool mandatory;
bool block;
+ bool queued;
unsigned int work_block;
int id;