Commit dcac23dbd856c46c58bf016ba3a176c96132bf57

Con Kolivas 2014-01-31T21:51:34

Discard work that is stale in the get_queued() function, returning NULL instead.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/cgminer.c b/cgminer.c
index 73d30f9..e6e9dcd 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6374,9 +6374,15 @@ struct work *get_queued(struct cgpu_info *cgpu)
 	wr_lock(&cgpu->qlock);
 	if (cgpu->unqueued_work) {
 		work = cgpu->unqueued_work;
+		if (unlikely(stale_work(work, false))) {
+			discard_work(work);
+			work = NULL;
+			goto out_unlock;
+		}
 		__add_queued(cgpu, work);
 		cgpu->unqueued_work = NULL;
 	}
+out_unlock:
 	wr_unlock(&cgpu->qlock);
 
 	return work;