Browse Source

Use only a trylock in flush queue to prevent deadlocks.

Con Kolivas 12 years ago
parent
commit
aa9938973e
1 changed files with 7 additions and 1 deletions
  1. 7 1
      cgminer.c

+ 7 - 1
cgminer.c

@@ -6614,7 +6614,13 @@ static void flush_queue(struct cgpu_info *cgpu)
 {
 {
 	struct work *work = NULL;
 	struct work *work = NULL;
 
 
-	wr_lock(&cgpu->qlock);
+	if (unlikely(!cgpu))
+		return;
+
+	/* Use only a trylock in case we get into a deadlock with a queueing
+	 * function holding the read lock when we're called. */
+	if (wr_trylock(&cgpu->qlock))
+		return;
 	work = cgpu->unqueued_work;
 	work = cgpu->unqueued_work;
 	cgpu->unqueued_work = NULL;
 	cgpu->unqueued_work = NULL;
 	wr_unlock(&cgpu->qlock);
 	wr_unlock(&cgpu->qlock);