From 0213b8baeddb969a95a5da64f34c1f533c749caa Mon Sep 17 00:00:00 2001 From: Linhai Date: Wed, 15 Dec 2021 02:43:49 -0500 Subject: [PATCH] fixing goroutine leaks in testServer --- pkg/proxy/server_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/proxy/server_test.go b/pkg/proxy/server_test.go index d2d98990e..6424cbb7c 100644 --- a/pkg/proxy/server_test.go +++ b/pkg/proxy/server_test.go @@ -96,6 +96,7 @@ func testServer(t *testing.T, scheme string, secure bool, delayTx bool) { writec <- data1 now := time.Now() if d := <-recvc; !bytes.Equal(data1, d) { + close(writec) t.Fatalf("expected %q, got %q", string(data1), string(d)) } took1 := time.Since(now) @@ -110,6 +111,7 @@ func testServer(t *testing.T, scheme string, secure bool, delayTx bool) { writec <- data2 now = time.Now() if d := <-recvc; !bytes.Equal(data2, d) { + close(writec) t.Fatalf("expected %q, got %q", string(data2), string(d)) } took2 := time.Since(now) @@ -122,6 +124,7 @@ func testServer(t *testing.T, scheme string, secure bool, delayTx bool) { if delayTx { p.UndelayTx() if took2 < lat-rv { + close(writec) t.Fatalf("expected took2 %v (with latency) > delay: %v", took2, lat-rv) } }