Skip to content

Commit

Permalink
fix: deadlock for blocking channel
Browse files Browse the repository at this point in the history
  • Loading branch information
rfyiamcool committed May 7, 2023
1 parent f6cb61e commit a8a9b49
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,10 @@ func (s *Scheduler) Stop() {
}

func (s *Scheduler) stop() {
s.setRunning(false)
s.stopJobs(s.jobs)
s.executor.stop()
s.StopBlockingChan()
s.setRunning(false)
}

func (s *Scheduler) stopJobs(jobs []*Job) {
Expand Down Expand Up @@ -1376,7 +1376,7 @@ func (s *Scheduler) CustomTimer(customTimer func(d time.Duration, f func()) *tim

func (s *Scheduler) StopBlockingChan() {
s.startBlockingStopChanMutex.Lock()
if s.startBlockingStopChan != nil {
if s.IsRunning() && s.startBlockingStopChan != nil {
close(s.startBlockingStopChan)
}
s.startBlockingStopChanMutex.Unlock()
Expand Down

0 comments on commit a8a9b49

Please sign in to comment.