Don't set reconnect parameters when the server has already responded. (#1779)
This commit is contained in:
@ -1119,8 +1119,8 @@ func (ac *addrConn) createTransport(connectRetryNum, ridx int, backoffDeadline,
|
|||||||
}
|
}
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
onPrefaceReceipt := func() {
|
onPrefaceReceipt := func() {
|
||||||
close(done)
|
|
||||||
ac.mu.Lock()
|
ac.mu.Lock()
|
||||||
|
close(done)
|
||||||
if !ac.backoffDeadline.IsZero() {
|
if !ac.backoffDeadline.IsZero() {
|
||||||
// If we haven't already started reconnecting to
|
// If we haven't already started reconnecting to
|
||||||
// other backends.
|
// other backends.
|
||||||
@ -1185,10 +1185,16 @@ func (ac *addrConn) createTransport(connectRetryNum, ridx int, backoffDeadline,
|
|||||||
close(ac.ready)
|
close(ac.ready)
|
||||||
ac.ready = nil
|
ac.ready = nil
|
||||||
}
|
}
|
||||||
ac.connectRetryNum = connectRetryNum
|
select {
|
||||||
ac.backoffDeadline = backoffDeadline
|
case <-done:
|
||||||
ac.connectDeadline = connectDeadline
|
// If the server has responded back with preface already,
|
||||||
ac.reconnectIdx = i + 1 // Start reconnecting from the next backend in the list.
|
// 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()
|
ac.mu.Unlock()
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user