Skip to content

Commit 6a1d6b6

Browse files
author
Ezequiel Raynaudo
authored
Merge pull request #22 from Zondax/bug_fix
Fix sending EmptyQueueChan when inputChan is also empty
2 parents f4ff057 + 398ff4e commit 6a1d6b6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

workers/workQueue/dispatcher.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewJobDispatcher() *JobDispatcher {
2626
retryTimeout: DefaultRetryTimeout,
2727
jobPool: NewJobPool(),
2828
workerChan: make(chan chan Work),
29-
inputChan: make(chan Work),
29+
inputChan: make(chan Work, 1),
3030
endChan: make(chan bool),
3131
EmptyQueueChan: make(chan bool),
3232
}
@@ -53,7 +53,9 @@ func (j *JobDispatcher) Start() {
5353
work := j.jobPool.GetNewJob()
5454
if work.JobId == -1 {
5555
zap.S().Infof("*** No more jobs on JobPool, waiting.... ***")
56-
j.EmptyQueueChan <- true
56+
if len(j.inputChan) == 0 {
57+
j.EmptyQueueChan <- true
58+
}
5759
time.Sleep(j.retryTimeout)
5860
continue
5961
}

0 commit comments

Comments
 (0)