Fix errors after rebasing

This commit is contained in:
Menghan Li 2016-07-26 14:28:36 -07:00
parent 4bbb9d8142
commit f6b46c1787
4 changed files with 21 additions and 9 deletions

View File

@ -473,12 +473,19 @@ func (cc *ClientConn) getTransport(ctx context.Context, opts BalancerGetOptions)
) )
if cc.dopts.balancer == nil { if cc.dopts.balancer == nil {
// If balancer is nil, there should be only one addrConn available. // If balancer is nil, there should be only one addrConn available.
cc.mu.RLock()
for _, ac = range cc.conns { for _, ac = range cc.conns {
// Break after the first loop to get the first addrConn. // Break after the first loop to get the first addrConn.
ok = true
break break
} }
cc.mu.RUnlock()
} else { } else {
addr, put, err := cc.dopts.balancer.Get(ctx, opts) var (
addr Address
err error
)
addr, put, err = cc.dopts.balancer.Get(ctx, opts)
if err != nil { if err != nil {
return nil, nil, toRPCErr(err) return nil, nil, toRPCErr(err)
} }
@ -489,13 +496,13 @@ func (cc *ClientConn) getTransport(ctx context.Context, opts BalancerGetOptions)
} }
ac, ok = cc.conns[addr] ac, ok = cc.conns[addr]
cc.mu.RUnlock() cc.mu.RUnlock()
}
if !ok { if !ok {
if put != nil { if put != nil {
put() put()
} }
return nil, nil, Errorf(codes.Internal, "grpc: failed to find the transport to send the rpc") return nil, nil, Errorf(codes.Internal, "grpc: failed to find the transport to send the rpc")
} }
}
t, err := ac.wait(ctx, !opts.BlockingWait) t, err := ac.wait(ctx, !opts.BlockingWait)
if err != nil { if err != nil {
if put != nil { if put != nil {

View File

@ -2284,7 +2284,7 @@ var clientAlwaysFailCredError = errors.New(clientAlwaysFailCredErrorMsg)
type clientAlwaysFailCred struct{} type clientAlwaysFailCred struct{}
func (c clientAlwaysFailCred) ClientHandshake(addr string, rawConn net.Conn, timeout time.Duration) (_ net.Conn, _ credentials.AuthInfo, err error) { func (c clientAlwaysFailCred) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
return nil, nil, clientAlwaysFailCredError return nil, nil, clientAlwaysFailCredError
} }
func (c clientAlwaysFailCred) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (c clientAlwaysFailCred) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {

View File

@ -774,7 +774,7 @@ func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
if t.state == reachable || t.state == draining { if t.state == reachable || t.state == draining {
if f.LastStreamID > 0 && f.LastStreamID%2 != 1 { if f.LastStreamID > 0 && f.LastStreamID%2 != 1 {
t.mu.Unlock() t.mu.Unlock()
t.notifyError(ConnectionErrorf("received illegal http2 GOAWAY frame: stream ID %d is even", f.LastStreamID)) t.notifyError(ConnectionErrorf(true, nil, "received illegal http2 GOAWAY frame: stream ID %d is even", f.LastStreamID))
return return
} }
select { select {
@ -783,7 +783,7 @@ func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
// t.goAway has been closed (i.e.,multiple GoAways). // t.goAway has been closed (i.e.,multiple GoAways).
if id < f.LastStreamID { if id < f.LastStreamID {
t.mu.Unlock() t.mu.Unlock()
t.notifyError(ConnectionErrorf("received illegal http2 GOAWAY frame: previously recv GOAWAY frame with LastStramID %d, currently recv %d", id, f.LastStreamID)) t.notifyError(ConnectionErrorf(true, nil, "received illegal http2 GOAWAY frame: previously recv GOAWAY frame with LastStramID %d, currently recv %d", id, f.LastStreamID))
return return
} }
t.prevGoAwayID = id t.prevGoAwayID = id

View File

@ -512,6 +512,11 @@ func (e ConnectionError) Temporary() bool {
// OriginalError returns the original error of this connection error. // OriginalError returns the original error of this connection error.
func (e ConnectionError) OriginalError() error { func (e ConnectionError) OriginalError() error {
// Never return nil error here.
// If original error is nil, return itself.
if e.origErr == nil {
return e
}
return e.origErr return e.origErr
} }