From 374cc8d72052324ea681fedd1ff9131c182c469a Mon Sep 17 00:00:00 2001 From: Michel Vocks Date: Thu, 23 Aug 2018 09:09:35 +0200 Subject: [PATCH] fixed race condition on channel close while go routine was sending (#85) --- scheduler/scheduler.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index fada0388..0f9b6d7f 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -522,6 +522,17 @@ func (s *Scheduler) executeScheduler(r *gaia.PipelineRun, pS Plugin) { // Send done signal to all resolvers close(done) + // read all jobs which are waiting to be executed to free the channel + var channelClean = false + for !channelClean { + select { + case <-executeScheduler: + // just read from the channel + default: + channelClean = true + } + } + // Close executeScheduler. No new jobs should be scheduled. close(executeScheduler)