Don't set reconnect parameters when the server has already responded. (#1779)

This commit is contained in:
mmukhi 2018-01-04 11:16:47 -08:00 коммит произвёл GitHub
Родитель 7aea499f91
Коммит e975017b47
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -1119,8 +1119,8 @@ func (ac *addrConn) createTransport(connectRetryNum, ridx int, backoffDeadline,
}
done := make(chan struct{})
onPrefaceReceipt := func() {
close(done)
ac.mu.Lock()
close(done)
if !ac.backoffDeadline.IsZero() {
// If we haven't already started reconnecting to
// other backends.
@ -1185,10 +1185,16 @@ func (ac *addrConn) createTransport(connectRetryNum, ridx int, backoffDeadline,
close(ac.ready)
ac.ready = nil
}
select {
case <-done:
// If the server has responded back with preface already,
// don't set the reconnect parameters.
default:
ac.connectRetryNum = connectRetryNum
ac.backoffDeadline = backoffDeadline
ac.connectDeadline = connectDeadline
ac.reconnectIdx = i + 1 // Start reconnecting from the next backend in the list.
}
ac.mu.Unlock()
return true, nil
}