v.io/x/ref: fix some context.CancelFunc leaks
Fix some leaks of context.CancelFunc.
They are just in tests---this is merely to silence the leak detector
( see https://vanadium-review.googlesource.com/#/c/22953/ )
Change-Id: I471acaaa922b140497b7dd967041fc6604d78ab8
diff --git a/runtime/internal/naming/namespace/all_test.go b/runtime/internal/naming/namespace/all_test.go
index 570eae7..364e0df 100644
--- a/runtime/internal/naming/namespace/all_test.go
+++ b/runtime/internal/naming/namespace/all_test.go
@@ -215,6 +215,7 @@
ctx, cancel := context.WithCancel(ctx)
_, s, err := v23.WithNewDispatchingServer(ctx, mountPoint, disp, options.ServesMountTable(mt))
if err != nil {
+ cancel()
boom(t, "r.NewServer: %s", err)
}
eps := s.Status().Endpoints
@@ -655,6 +656,7 @@
// Setup the namespace root for all the "processes".
rootmt := runMT(t, rootMtCtx, "")
+ defer rootmt.stop()
for _, ctx := range []*context.T{mtCtx, serverCtx, clientCtx} {
v23.GetNamespace(ctx).SetRoots(rootmt.name)
}
diff --git a/services/device/deviced/internal/impl/impl_helper_test.go b/services/device/deviced/internal/impl/impl_helper_test.go
index f500671..934d31d 100644
--- a/services/device/deviced/internal/impl/impl_helper_test.go
+++ b/services/device/deviced/internal/impl/impl_helper_test.go
@@ -20,7 +20,8 @@
)
func TestBaseCleanupDir(t *testing.T) {
- ctx, _ := context.RootContext()
+ ctx, cancel := context.RootContext()
+ defer cancel()
ctx = context.WithLogger(ctx, logger.Global())
dir, err := ioutil.TempDir("", "impl_helper_test")
if err != nil {