Browse Source

Bugfix: Now that stage_work is trying to manipulate staged_work in the same thread, clone_available needs to stage it outside of its own lock

Luke Dashjr 13 years ago
parent
commit
6276c31f4e
1 changed files with 6 additions and 4 deletions
  1. 6 4
      miner.c

+ 6 - 4
miner.c

@@ -3349,6 +3349,7 @@ static void stage_work(struct work *work);
 static bool clone_available(void)
 static bool clone_available(void)
 {
 {
 	struct work *work, *tmp;
 	struct work *work, *tmp;
+	struct work *work_clone;
 	bool cloned = false;
 	bool cloned = false;
 
 
 	if (!staged_rollable)
 	if (!staged_rollable)
@@ -3357,19 +3358,20 @@ static bool clone_available(void)
 	mutex_lock(stgd_lock);
 	mutex_lock(stgd_lock);
 	HASH_ITER(hh, staged_work, work, tmp) {
 	HASH_ITER(hh, staged_work, work, tmp) {
 		if (can_roll(work) && should_roll(work)) {
 		if (can_roll(work) && should_roll(work)) {
-			struct work *work_clone;
-
 			roll_work(work);
 			roll_work(work);
 			work_clone = make_clone(work);
 			work_clone = make_clone(work);
 			roll_work(work);
 			roll_work(work);
-			applog(LOG_DEBUG, "Pushing cloned available work to stage thread");
-			stage_work(work_clone);
 			cloned = true;
 			cloned = true;
 			break;
 			break;
 		}
 		}
 	}
 	}
 	mutex_unlock(stgd_lock);
 	mutex_unlock(stgd_lock);
 
 
+	if (cloned) {
+		applog(LOG_DEBUG, "Pushing cloned available work to stage thread");
+		stage_work(work_clone);
+	}
+
 out:
 out:
 	return cloned;
 	return cloned;
 }
 }