Skip to content

Commit

Permalink
Bugfix: Now that stage_work is trying to manipulate staged_work in th…
Browse files Browse the repository at this point in the history
…e same thread, clone_available needs to stage it outside of its own lock
  • Loading branch information
luke-jr committed Dec 9, 2012
1 parent c408f6b commit 6276c31
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -3349,6 +3349,7 @@ static void stage_work(struct work *work);
static bool clone_available(void)
{
struct work *work, *tmp;
struct work *work_clone;
bool cloned = false;

if (!staged_rollable)
Expand All @@ -3357,19 +3358,20 @@ static bool clone_available(void)
mutex_lock(stgd_lock);
HASH_ITER(hh, staged_work, work, tmp) {
if (can_roll(work) && should_roll(work)) {
struct work *work_clone;

roll_work(work);
work_clone = make_clone(work);
roll_work(work);
applog(LOG_DEBUG, "Pushing cloned available work to stage thread");
stage_work(work_clone);
cloned = true;
break;
}
}
mutex_unlock(stgd_lock);

if (cloned) {
applog(LOG_DEBUG, "Pushing cloned available work to stage thread");
stage_work(work_clone);
}

out:
return cloned;
}
Expand Down

0 comments on commit 6276c31

Please sign in to comment.