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

View File

@ -2284,7 +2284,7 @@ var clientAlwaysFailCredError = errors.New(clientAlwaysFailCredErrorMsg)
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
}
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 f.LastStreamID > 0 && f.LastStreamID%2 != 1 {
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
}
select {
@ -783,7 +783,7 @@ func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
// t.goAway has been closed (i.e.,multiple GoAways).
if id < f.LastStreamID {
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
}
t.prevGoAwayID = id

View File

@ -512,6 +512,11 @@ func (e ConnectionError) Temporary() bool {
// OriginalError returns the original error of this connection 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
}