diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 5 |
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) } } |