summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-09 04:48:28 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-09 04:48:28 +0000
commitf7540b7715bf8e3be66aa79dca519c5032f34233 (patch)
tree8b9a0983f438b9a8d1d83cba3f83ce408f748d9d /server
parente78073e0abf87bee0fd6a21744cb6bf7188f4bb7 (diff)
server: don't block select loop by Sleep(), use Timer instead
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/fsm.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/fsm.go b/server/fsm.go
index 34f8b1f1..0f3e5538 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -308,6 +308,9 @@ func (fsm *FSM) connectLoop() error {
ticker := time.NewTicker(time.Duration(tick) * time.Second)
ticker.Stop()
+ timer := time.NewTimer(time.Duration(tick) * time.Second)
+ timer.Stop()
+
connect := func() {
if fsm.state == bgp.BGP_FSM_ACTIVE && !fsm.pConf.GracefulRestart.State.PeerRestarting {
addr := fsm.pConf.Config.NeighborAddress
@@ -366,12 +369,13 @@ func (fsm *FSM) connectLoop() error {
}).Debug("stop connect loop")
ticker.Stop()
return nil
+ case <-timer.C:
+ ticker = time.NewTicker(time.Duration(tick) * time.Second)
+ connect()
case <-ticker.C:
connect()
case <-fsm.getActiveCh:
- time.Sleep(time.Duration(r.Intn(MIN_CONNECT_RETRY)+MIN_CONNECT_RETRY) * time.Second)
- connect()
- ticker = time.NewTicker(time.Duration(tick) * time.Second)
+ timer.Reset(time.Duration(r.Intn(MIN_CONNECT_RETRY)+MIN_CONNECT_RETRY) * time.Second)
}
}
}