Skip to content

Commit

Permalink
Merge pull request etcd-io#13540 from songlh-psu/fixing-3
Browse files Browse the repository at this point in the history
fixing one panic and two goroutine leaks
  • Loading branch information
ptabor authored Dec 21, 2021
2 parents 1e4a345 + 5e8f50b commit 6927953
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon

select {
case <-ctx.Done():
resp.Body.Close()
if resp != nil {
resp.Body.Close()
}
<-done
return nil, nil, ctx.Err()
case <-done:
Expand Down
6 changes: 4 additions & 2 deletions server/storage/mvcc/watchable_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func TestWatch(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})

defer func() {
s.store.Close()
b.Close()
s.Close()
os.Remove(tmpPath)
}()

Expand Down Expand Up @@ -536,7 +537,8 @@ func TestWatchVictims(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})

defer func() {
s.store.Close()
b.Close()
s.Close()
os.Remove(tmpPath)
chanBufLen, maxWatchersPerSync = oldChanBufLen, oldMaxWatchersPerSync
}()
Expand Down

0 comments on commit 6927953

Please sign in to comment.