Skip to content

Commit

Permalink
sealing sched: Fix deadleck witween worker.wndLk / workersLk
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Sep 2, 2020
1 parent b7f2487 commit a05cd2f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions extern/sector-storage/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ func (sh *scheduler) runWorker(wid WorkerID) {
return
}

sh.workersLk.RLock()
worker.wndLk.Lock()

windowsRequested -= sh.workerCompactWindows(worker, wid)
Expand All @@ -574,8 +575,6 @@ func (sh *scheduler) runWorker(wid WorkerID) {

// process tasks within a window, preferring tasks at lower indexes
for len(firstWindow.todo) > 0 {
sh.workersLk.RLock()

tidx := -1

worker.lk.Lock()
Expand All @@ -589,15 +588,13 @@ func (sh *scheduler) runWorker(wid WorkerID) {
worker.lk.Unlock()

if tidx == -1 {
sh.workersLk.RUnlock()
break assignLoop
}

todo := firstWindow.todo[tidx]

log.Debugf("assign worker sector %d", todo.sector.Number)
err := sh.assignWorker(taskDone, wid, worker, todo)
sh.workersLk.RUnlock()

if err != nil {
log.Error("assignWorker error: %+v", err)
Expand All @@ -618,6 +615,7 @@ func (sh *scheduler) runWorker(wid WorkerID) {
}

worker.wndLk.Unlock()
sh.workersLk.RUnlock()
}
}()
}
Expand Down

0 comments on commit a05cd2f

Please sign in to comment.