Make sure to have at least one staged work item when deciding whether to queue another request or not and dec queued in free work not discard work.
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
diff --git a/cgminer.c b/cgminer.c
index 483331a..1e85437 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1892,8 +1892,17 @@ static struct work *make_work(void)
return work;
}
+static inline void dec_queued(void)
+{
+ if (likely(total_queued > 0))
+ total_queued--;
+}
+
static void free_work(struct work *work)
{
+ if (!work->clone)
+ dec_queued();
+
free(work);
}
@@ -2377,17 +2386,8 @@ static inline void inc_queued(void)
total_queued++;
}
-static inline void dec_queued(void)
-{
- if (likely(total_queued > 0))
- total_queued--;
-}
-
static void discard_work(struct work *work)
{
- if (!work->clone)
- dec_queued();
-
if (!work->clone && !work->rolls && !work->mined) {
if (work->pool)
work->pool->discarded_work++;
@@ -3496,7 +3496,7 @@ static bool queue_request(struct thr_info *thr, bool needed)
struct workio_cmd *wc;
if ((total_queued >= opt_queue && rs >= mining_threads) ||
- total_queued >= mining_threads)
+ (total_queued >= mining_threads && rs))
return true;
/* fill out work request message */