Merge branch 'backoff-retry' of dan/cwtch into master

这个提交包含在:
Sarah Jamie Lewis 2019-03-29 13:43:49 -07:00 提交者 Gogs
当前提交 45b1a10fff
共有 2 个文件被更改,包括 9 次插入4 次删除

查看文件

@ -99,7 +99,9 @@ func (m *Manager) GetPeerServerConnectionForOnion(host string) (psc *PeerServerC
// AttemptReconnections repeatedly attempts to reconnect with failed peers and servers.
func (m *Manager) AttemptReconnections() {
timeout := time.Duration(0) // first pass right away
maxTimeout := time.Minute * 5
// nearly instant first run, next few runs will prolly be too quick to have any FAILED and will gracefully slow to MAX after that
timeout := time.Millisecond * 500
for {
select {
@ -120,8 +122,11 @@ func (m *Manager) AttemptReconnections() {
}
m.lock.Unlock()
// Launch Another Run In 30 Seconds
timeout = time.Duration(30 * time.Second)
if timeout < maxTimeout {
timeout = timeout * 2
} else {
timeout = maxTimeout
}
case <-m.breakChannel:
return
}

查看文件

@ -102,7 +102,7 @@ func (psc *PeerServerConnection) SendGroupMessage(gm *protocol.GroupMessage) err
errCount := 0
for errCount < 5 {
time.Sleep(time.Second * 1)
time.Sleep(time.Second * time.Duration(errCount+1)) // back off retry
err = psc.connection.Do(func() error {
channel := psc.connection.Channel("im.cwtch.server.send", channels.Outbound)
if channel == nil {