Skip to content

Commit

Permalink
sched: Fix taskDone chan deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 3, 2021
1 parent b87142e commit 9af82f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extern/sector-storage/sched_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ func (sw *schedWorker) startProcessingTask(req *workerRequest) error {
case sw.taskDone <- struct{}{}:
case <-sh.closing:
log.Warnf("scheduler closed while sending response (prepare error: %+v)", err)
default: // there is a notification pending already
}

select {
Expand All @@ -496,6 +497,7 @@ func (sw *schedWorker) startProcessingTask(req *workerRequest) error {
select {
case sw.taskDone <- struct{}{}:
case <-sh.closing:
default: // there is a notification pending already
}

// Do the work!
Expand Down Expand Up @@ -550,6 +552,7 @@ func (sw *schedWorker) startProcessingReadyTask(req *workerRequest) error {
case sw.taskDone <- struct{}{}:
case <-sh.closing:
log.Warnf("scheduler closed while sending response (prepare error: %+v)", err)
default: // there is a notification pending already
}

w.lk.Unlock()
Expand Down

0 comments on commit 9af82f2

Please sign in to comment.