Commit 5fadfdb2195b941ae04e4e12c7c7e2addde9594d

Con Kolivas 2012-08-16T09:19:45

Overlap queued decrementing with staged incrementing.

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;