fixing goroutine leaks

This commit is contained in:
Linhai 2021-12-24 15:57:38 -05:00
parent 69279532f4
commit 98b0d901e8
4 changed files with 7 additions and 3 deletions

View File

@ -33,7 +33,7 @@ import (
) )
func dummyIndexWaiter(index uint64) <-chan struct{} { func dummyIndexWaiter(index uint64) <-chan struct{} {
ch := make(chan struct{}) ch := make(chan struct{}, 1)
go func() { go func() {
ch <- struct{}{} ch <- struct{}{}
}() }()

View File

@ -722,6 +722,8 @@ func TestConcurrentReadTxAndWrite(t *testing.T) {
) )
b, tmpPath := betesting.NewDefaultTmpBackend(t) b, tmpPath := betesting.NewDefaultTmpBackend(t)
s := NewStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{}) s := NewStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer b.Close()
defer s.Close()
defer os.Remove(tmpPath) defer os.Remove(tmpPath)
var wg sync.WaitGroup var wg sync.WaitGroup

View File

@ -265,7 +265,8 @@ func TestWatchFutureRev(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{}) s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer func() { defer func() {
s.store.Close() b.Close()
s.Close()
os.Remove(tmpPath) os.Remove(tmpPath)
}() }()

View File

@ -216,7 +216,8 @@ func TestWatchDeleteRange(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{}) s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer func() { defer func() {
s.store.Close() b.Close()
s.Close()
os.Remove(tmpPath) os.Remove(tmpPath)
}() }()