Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Unified Diff: go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go

Issue 1223263006: Use SetFinalizer to avoid leaking Snapshots. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@abstract
Patch Set: rebase on origin/master Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
diff --git a/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go b/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
index a21c9bbad1354b14cdc2029ddcdeb74e630c434c..08b2b9b075ecfd5b73c37922d59e293cfb300d83 100644
--- a/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
+++ b/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
@@ -6,6 +6,7 @@ package memory
import (
"bytes"
+ "runtime"
"sync"
"github.com/luci/gkvlite"
@@ -75,7 +76,11 @@ func newMemStore() *memStore {
}
func (ms *memStore) Snapshot() *memStore {
- return (*memStore)((*gkvlite.Store)(ms).Snapshot())
+ ret := (*memStore)((*gkvlite.Store)(ms).Snapshot())
+ runtime.SetFinalizer((*gkvlite.Store)(ret), func(s *gkvlite.Store) {
+ go s.Close()
+ })
+ return ret
}
func (ms *memStore) MakePrivateCollection(cmp gkvlite.KeyCompare) *memCollection {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698