Skip to content

Commit

Permalink
Fix data race in TestServerGoAwayPendingRPC (grpc#1862)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Feb 14, 2018
1 parent e014063 commit 445b728
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,18 +940,18 @@ func testServerGoAwayPendingRPC(t *testing.T, e env) {
close(ch)
}()
// Loop until the server side GoAway signal is propagated to the client.
abort := false
time.AfterFunc(time.Second, func() { abort = true })
for !abort {
start := time.Now()
errored := false
for time.Since(start) < time.Second {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.FailFast(false)); err != nil {
cancel()
_, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.FailFast(false))
cancel()
if err != nil {
errored = true
break
}
cancel()
}
// Don't bother stopping the timer; it will have no effect past here.
if abort {
if !errored {
t.Fatalf("GoAway never received by client")
}
respParam := []*testpb.ResponseParameters{{Size: 1}}
Expand Down

0 comments on commit 445b728

Please sign in to comment.