From 716496ec42940478875230d045813a7076692f10 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 15 May 2014 23:18:59 -0400 Subject: [PATCH] chore(standby_server): still sleep for the first time --- server/standby_server.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/server/standby_server.go b/server/standby_server.go index 8f18755f4..b9c7f29d8 100644 --- a/server/standby_server.go +++ b/server/standby_server.go @@ -168,19 +168,17 @@ func (s *StandbyServer) redirectRequests(w http.ResponseWriter, r *http.Request) uhttp.Redirect(leader.ClientURL, w, r) } +// monitorCluster assumes that the machine has tried to join the cluster and +// failed, so it waits for the interval at the beginning. func (s *StandbyServer) monitorCluster() { - first := true for { - if !first { - timer := time.NewTimer(time.Duration(int64(s.syncInterval * float64(time.Second)))) - defer timer.Stop() - select { - case <-s.closeChan: - return - case <-timer.C: - } + timer := time.NewTimer(time.Duration(int64(s.syncInterval * float64(time.Second)))) + defer timer.Stop() + select { + case <-s.closeChan: + return + case <-timer.C: } - first = false if err := s.syncCluster(nil); err != nil { log.Warnf("fail syncing cluster(%v): %v", s.Cluster(), err)