resetTransport: log all transient errors when they occur

Previously, cancellation of the context would cause these transient
errors to be swallowed since the function would return before the
log line was reached.
This commit is contained in:
Tamir Duberstein 2016-08-10 12:37:53 -04:00
parent 6140c2e83c
commit 5e62f80ba8
No known key found for this signature in database
GPG Key ID: 1C1E98CC8E17BB89
1 changed files with 2 additions and 4 deletions

View File

@ -609,8 +609,7 @@ func (ac *addrConn) waitForStateChange(ctx context.Context, sourceState Connecti
}
func (ac *addrConn) resetTransport(closeTransport bool) error {
var retries int
for {
for retries := 0; ; retries++ {
ac.mu.Lock()
ac.printf("connecting")
if ac.state == Shutdown {
@ -643,6 +642,7 @@ func (ac *addrConn) resetTransport(closeTransport bool) error {
if e, ok := err.(transport.ConnectionError); ok && !e.Temporary() {
return err
}
grpclog.Printf("grpc: addrConn.resetTransport failed to create client transport: %v; Reconnecting to %q", err, ac.addr)
ac.mu.Lock()
if ac.state == Shutdown {
// ac.tearDown(...) has been invoked.
@ -663,8 +663,6 @@ func (ac *addrConn) resetTransport(closeTransport bool) error {
case <-ac.ctx.Done():
return ac.ctx.Err()
}
retries++
grpclog.Printf("grpc: addrConn.resetTransport failed to create client transport: %v; Reconnecting to %q", err, ac.addr)
continue
}
ac.mu.Lock()