diff --git a/common/utils/workerpool/workerpool.go b/common/utils/workerpool/workerpool.go index a779c4f690..aebe3ba475 100644 --- a/common/utils/workerpool/workerpool.go +++ b/common/utils/workerpool/workerpool.go @@ -25,12 +25,8 @@ func (vwp *WorkerPool) Run() { for i := 0; i < vwp.maxWorker; i++ { go func() { for task := range vwp.taskQueueChan { - if task != nil { - task() - vwp.wg.Done() - } else { - return - } + task() + vwp.wg.Done() } }() } @@ -45,6 +41,9 @@ func (vwp *WorkerPool) Stop() { // AddTask adds a task to WorkerPool func (vwp *WorkerPool) AddTask(task func()) { + if task == nil { + return + } vwp.wg.Add(1) vwp.taskQueueChan <- task }