take_queued_work_bymidstate should use a write lock.
diff --git a/cgminer.c b/cgminer.c
index fc611a4..3b9e3ba 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6178,11 +6178,11 @@ struct work *take_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate,
{
struct work *work;
- rd_lock(&cgpu->qlock);
+ wr_lock(&cgpu->qlock);
work = __find_work_bymidstate(cgpu->queued_work, midstate, midstatelen, data, offset, datalen);
if (work)
__work_completed(cgpu, work);
- rd_unlock(&cgpu->qlock);
+ wr_unlock(&cgpu->qlock);
return work;
}