mirror of https://github.com/grpc/grpc-go.git
grpc: perform a blocking close of the balancer in ccb (#6497)
This commit is contained in:
parent
ecc5645b95
commit
5d3d9d7ca5
|
@ -226,11 +226,9 @@ func (ccb *ccBalancerWrapper) closeBalancer(m ccbMode) {
|
|||
}
|
||||
ccb.mu.Unlock()
|
||||
|
||||
// Give enqueued callbacks a chance to finish.
|
||||
// Give enqueued callbacks a chance to finish before closing the balancer.
|
||||
<-done
|
||||
// Spawn a goroutine to close the balancer (since it may block trying to
|
||||
// cleanup all allocated resources) and return early.
|
||||
go b.Close()
|
||||
b.Close()
|
||||
}
|
||||
|
||||
// exitIdleMode is invoked by grpc when the channel exits idle mode either
|
||||
|
|
|
@ -408,17 +408,20 @@ func (s) TestChannelIdleness_Enabled_IdleTimeoutRacesWithRPCs(t *testing.T) {
|
|||
// Verify that the ClientConn moves to READY.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
|
||||
defer cancel()
|
||||
awaitState(ctx, t, cc, connectivity.Ready)
|
||||
client := testgrpc.NewTestServiceClient(cc)
|
||||
if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err != nil {
|
||||
t.Errorf("EmptyCall RPC failed: %v", err)
|
||||
}
|
||||
|
||||
// Make an RPC every defaultTestShortTimeout duration so as to race with the
|
||||
// idle timeout. Whether the idle timeout wins the race or the RPC wins the
|
||||
// race, RPCs must succeed.
|
||||
client := testgrpc.NewTestServiceClient(cc)
|
||||
for i := 0; i < 20; i++ {
|
||||
<-time.After(defaultTestShortTimeout)
|
||||
if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err != nil {
|
||||
t.Errorf("EmptyCall RPC failed: %v", err)
|
||||
t.Fatalf("EmptyCall RPC failed: %v", err)
|
||||
}
|
||||
t.Logf("Iteration %d succeeded", i)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue