New backoff (#1153)
* new backoff function * use backoff from util/backoff * remove reset atemts * change comment * fmt
This commit is contained in:
@@ -225,9 +225,6 @@ func (n *network) acceptNetConn(l tunnel.Listener, recv chan *message) {
|
||||
sleep := backoff.Do(i)
|
||||
log.Debugf("Network tunnel [%s] accept error: %v, backing off for %v", ControlChannel, err, sleep)
|
||||
time.Sleep(sleep)
|
||||
if i > 5 {
|
||||
i = 0
|
||||
}
|
||||
i++
|
||||
continue
|
||||
}
|
||||
@@ -255,10 +252,6 @@ func (n *network) acceptCtrlConn(l tunnel.Listener, recv chan *message) {
|
||||
sleep := backoff.Do(i)
|
||||
log.Debugf("Network tunnel [%s] accept error: %v, backing off for %v", ControlChannel, err, sleep)
|
||||
time.Sleep(sleep)
|
||||
if i > 5 {
|
||||
// reset the counter
|
||||
i = 0
|
||||
}
|
||||
i++
|
||||
continue
|
||||
}
|
||||
@@ -1572,11 +1565,6 @@ func (n *network) connect() {
|
||||
case <-time.After(time.Second + backoff.Do(attempts)):
|
||||
// we have to try again
|
||||
attempts++
|
||||
|
||||
// reset attempts 5 == ~2mins
|
||||
if attempts > 5 {
|
||||
attempts = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user