Skip to content

Commit

Permalink
resolve race
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuxuan committed Oct 5, 2017
1 parent 51622b0 commit f539b14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,8 @@ type jsonSC struct {
// handleServiceConfig parses the service config string in JSON format to Go native
// struct ServiceConfig, and store both the struct and the JSON string in ClientConn.
func (cc *ClientConn) handleServiceConfig(js string) error {
cc.mu.Lock()
defer cc.mu.Unlock()
var rsc jsonSC
err := json.Unmarshal([]byte(js), &rsc)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions test/end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ func testServiceConfigMaxMsgSize(t *testing.T, e env) {
}

// Test for unary RPC recv.
if _, err = tc.UnaryCall(context.Background(), req); err == nil || grpc.Code(err) != codes.ResourceExhausted {
if _, err = tc.UnaryCall(context.Background(), req, grpc.FailFast(false)); err == nil || grpc.Code(err) != codes.ResourceExhausted {
t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
}

Expand Down Expand Up @@ -1695,7 +1695,7 @@ func testServiceConfigMaxMsgSize(t *testing.T, e env) {
req.Payload = smallPayload
req.ResponseSize = proto.Int32(int32(largeSize))

if _, err = tc.UnaryCall(context.Background(), req); err == nil || grpc.Code(err) != codes.ResourceExhausted {
if _, err = tc.UnaryCall(context.Background(), req, grpc.FailFast(false)); err == nil || grpc.Code(err) != codes.ResourceExhausted {
t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
}

Expand Down Expand Up @@ -1760,7 +1760,7 @@ func testServiceConfigMaxMsgSize(t *testing.T, e env) {
req.Payload = smallPayload
req.ResponseSize = proto.Int32(int32(largeSize))

if _, err = tc.UnaryCall(context.Background(), req); err != nil {
if _, err = tc.UnaryCall(context.Background(), req, grpc.FailFast(false)); err != nil {
t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want <nil>", err)
}

Expand Down

0 comments on commit f539b14

Please sign in to comment.