New backoff (#1153)

* new backoff function

* use backoff from util/backoff

* remove reset atemts

* change comment

* fmt
This commit is contained in:
tpam28
2020-02-02 23:32:55 +03:00
committed by GitHub
parent 079102ea59
commit 449bcb46fe
3 changed files with 8 additions and 18 deletions

View File

@@ -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
}
}
}
}