Skip to content

Commit 6610f9a

Browse files
authored
Fix test: Data race while resetting global var. (grpc#1748)
1 parent f4b5237 commit 6610f9a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clientconn_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,21 @@ func TestCloseConnectionWhenServerPrefaceNotReceived(t *testing.T) {
248248
t.Fatalf("Error while dialing. Err: %v", err)
249249
}
250250
<-done
251+
// TODO: The code from BEGIN to END should be delete once issue
252+
// https://github.com/grpc/grpc-go/issues/1750 is fixed.
253+
// BEGIN
254+
// Set underlying addrConns state to Shutdown so that no reconnect
255+
// attempts take place and thereby resetting minConnectTimeout is
256+
// race free.
257+
client.mu.Lock()
258+
addrConns := client.conns
259+
client.mu.Unlock()
260+
for ac := range addrConns {
261+
ac.mu.Lock()
262+
ac.state = connectivity.Shutdown
263+
ac.mu.Unlock()
264+
}
265+
// END
251266
client.Close()
252267
close(clientDone)
253268
}

0 commit comments

Comments
 (0)