Skip to content
Snippets Groups Projects
Commit a74bcabc authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Manager: attempt at preventing hanging at shutdown

A closed timer channel now no longer results in an infinite loop. Hopefully
this resolves the hanging shutdown.
parent 8bb8410b
No related branches found
No related tags found
No related merge requests found
...@@ -107,16 +107,22 @@ func (self *UpstreamConnection) download_task_loop() { ...@@ -107,16 +107,22 @@ func (self *UpstreamConnection) download_task_loop() {
self.done_wg.Add(1) self.done_wg.Add(1)
defer self.done_wg.Done() defer self.done_wg.Done()
defer log.Println("download_task_loop: Task download goroutine shutting down.")
for { for {
select { select {
case <-self.done: case <-self.done:
log.Println("download_task_loop: Task download goroutine shutting down.")
return return
case <-timer_chan: case _, ok := <-timer_chan:
if !ok {
return
}
log.Println("download_task_loop: Going to fetch tasks due to periodic timeout.") log.Println("download_task_loop: Going to fetch tasks due to periodic timeout.")
download_tasks_from_upstream(self.config, mongo_sess) download_tasks_from_upstream(self.config, mongo_sess)
case pingback_chan := <-self.download_kick: case pingback_chan, ok := <-self.download_kick:
if !ok {
return
}
log.Println("download_task_loop: Going to fetch tasks due to kick.") log.Println("download_task_loop: Going to fetch tasks due to kick.")
download_tasks_from_upstream(self.config, mongo_sess) download_tasks_from_upstream(self.config, mongo_sess)
if pingback_chan != nil { if pingback_chan != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment