Discard work that is stale in the get_queued() function, returning NULL instead.
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;