summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-01 09:41:40 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-04 16:46:28 +0900
commit013c9122853d70723c5b821cec66469f734c778c (patch)
tree73efce789d228e916d4b2163543c9b839a9c1cee
parent11c77a200330d28a0bdba425b5b42507a7dc19b3 (diff)
server: randomize trigger of active connect
fix connectivity issue when both bgpd is gobgpd Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--server/fsm.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/server/fsm.go b/server/fsm.go
index d435b08c..16267c17 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -23,6 +23,7 @@ import (
"github.com/osrg/gobgp/table"
"gopkg.in/tomb.v2"
"io"
+ "math/rand"
"net"
"strconv"
"time"
@@ -231,6 +232,8 @@ func (fsm *FSM) connectLoop() error {
tick = MIN_CONNECT_RETRY
}
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
+
ticker := time.NewTicker(time.Duration(tick) * time.Second)
ticker.Stop()
@@ -286,6 +289,8 @@ func (fsm *FSM) connectLoop() error {
case <-ticker.C:
connect()
case <-fsm.getActiveCh:
+ time.Sleep(time.Duration(r.Intn(tick)+MIN_CONNECT_RETRY) * time.Second)
+ connect()
ticker = time.NewTicker(time.Duration(tick) * time.Second)
}
}