diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index b2c19e79f28..3a0807bfc46 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -131,6 +131,7 @@ func (s *Supervisor) Run( var backoffTimer <-chan time.Time shuttingDown := false + gracefulShutdownC := s.gracefulShutdownC for { select { // Context cancelled @@ -175,8 +176,10 @@ func (s *Supervisor) Run( // No more tunnels outstanding, clear backoff timer backoff.SetGracePeriod() } - case <-s.gracefulShutdownC: + case <-gracefulShutdownC: shuttingDown = true + // Avoid making the loop spin while the tunnels drain. + gracefulShutdownC = nil } } }