From dc9f969673f831a713176fce7293e8c0c182f257 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 22 May 2020 15:34:59 -0700 Subject: [PATCH] Fix possible context leaks --- pkg/schema/collection.go | 1 + pkg/server/store/proxy/rbac_store.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/schema/collection.go b/pkg/schema/collection.go index 319d19c..ce0324e 100644 --- a/pkg/schema/collection.go +++ b/pkg/schema/collection.go @@ -150,6 +150,7 @@ func (c *Collection) startStopTemplate(schemas map[string]*types.APISchema) { subCtx, cancel := context.WithCancel(c.ctx) if err := template.Start(subCtx); err != nil { + cancel() logrus.Errorf("failed to start schema template: %s", id) continue } diff --git a/pkg/server/store/proxy/rbac_store.go b/pkg/server/store/proxy/rbac_store.go index a888e12..65ebfda 100644 --- a/pkg/server/store/proxy/rbac_store.go +++ b/pkg/server/store/proxy/rbac_store.go @@ -182,6 +182,7 @@ func (r *RBACStore) Watch(apiOp *types.APIRequest, schema *types.APISchema, w ty } ctx, cancel := context.WithCancel(apiOp.Context()) + defer cancel() apiOp = apiOp.WithContext(ctx) eg := errgroup.Group{}