Skip to content

Commit

Permalink
if job chains are used improperly we can end up with jobs with nil fu…
Browse files Browse the repository at this point in the history
…nctions (#388)

* if job chains are used improperly we can end up with jobs with nil functions

* Update executor.go

* Update executor.go
  • Loading branch information
JohnRoesler authored Oct 20, 2022
1 parent af043b7 commit 471bc39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (e *executor) start() {
case f := <-e.jobFunctions:
runningJobsWg.Add(1)
go func() {
defer runningJobsWg.Done()

panicHandlerMutex.RLock()
defer panicHandlerMutex.RUnlock()

Expand All @@ -58,8 +60,6 @@ func (e *executor) start() {
}()
}

defer runningJobsWg.Done()

if e.maxRunningJobs != nil {
if !e.maxRunningJobs.TryAcquire(1) {

Expand Down
7 changes: 7 additions & 0 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ func (s *Scheduler) run(job *Job) {
}

job.mu.Lock()

if job.function == nil {
job.mu.Unlock()
s.Remove(job)
return
}

defer job.mu.Unlock()

if job.runWithDetails {
Expand Down

0 comments on commit 471bc39

Please sign in to comment.