rpc: fix leak in TestClientHTTP by making errc buffered

This avoids adding an extra stop channel.
This commit is contained in:
Felix Lange 2020-04-03 13:54:20 +02:00
parent 5da0694ede
commit 42cd72aba4

View file

@ -413,21 +413,14 @@ func TestClientHTTP(t *testing.T) {
// Launch concurrent requests. // Launch concurrent requests.
var ( var (
results = make([]echoResult, 100) results = make([]echoResult, 100)
errc = make(chan error) errc = make(chan error, len(results))
wantResult = echoResult{"a", 1, new(echoArgs)} wantResult = echoResult{"a", 1, new(echoArgs)}
stop = make(chan struct{})
) )
defer close(stop)
defer client.Close() defer client.Close()
for i := range results { for i := range results {
i := i i := i
go func() { go func() {
select { errc <- client.Call(&results[i], "test_echo", wantResult.String, wantResult.Int, wantResult.Args)
case <-stop:
return
case errc <- client.Call(&results[i], "test_echo",
wantResult.String, wantResult.Int, wantResult.Args):
}
}() }()
} }