Use defer style to stop tickers to avoid current/possible misuse (#5883)

This commit ensures that all tickers are stopped using defer ticker.Stop()
style. This will also fix one bug seen when a client starts to listen to
event notifications and that case will result a leak in tickers.
This commit is contained in:
Anis Elleuch
2018-05-04 10:43:20 -07:00
committed by Dee Koder
parent 0f746a14a3
commit 9439dfef64
7 changed files with 14 additions and 13 deletions

View File

@@ -198,15 +198,14 @@ func (s *xlSets) connectDisks() {
// the set topology, this monitoring happens at a given monitoring interval.
func (s *xlSets) monitorAndConnectEndpoints(monitorInterval time.Duration) {
ticker := time.NewTicker(monitorInterval)
// Stop the timer.
defer ticker.Stop()
for {
select {
case <-globalServiceDoneCh:
// Stop the timer.
ticker.Stop()
return
case <-s.disksConnectDoneCh:
// Stop the timer.
ticker.Stop()
return
case <-ticker.C:
s.connectDisks()