Merge pull request #13537 from songlh/main

fix potential goroutine leaks
This commit is contained in:
Piotr Tabor 2021-12-21 10:47:54 +01:00 committed by GitHub
commit 0bdc660ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -27,7 +27,7 @@ func TestTxnPanics(t *testing.T) {
kv := &kv{}
errc := make(chan string, 1)
errc := make(chan string, 6)
df := func() {
if s := recover(); s != nil {
errc <- s.(string)

View File

@ -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)
}
}

View File

@ -32,7 +32,7 @@ func TestBackendClose(t *testing.T) {
b, _ := betesting.NewTmpBackend(t, time.Hour, 10000)
// check close could work
done := make(chan struct{})
done := make(chan struct{}, 1)
go func() {
err := b.Close()
if err != nil {