mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13537 from songlh/main
fix potential goroutine leaks
This commit is contained in:
commit
0bdc660ec2
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user