Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblanet <moweng.xx@alibaba-inc.com>2022-06-21 11:27:25 +0300
committerblanet <moweng.xx@alibaba-inc.com>2022-06-27 09:14:43 +0300
commit82d240016dd37cd95b04e7ccfd04f808dec2a70e (patch)
tree89ced0e91cb743edcda6500a5267a2b714e3032c
parent2ca37cd3341a7239cc22a1a684e21af6728be7be (diff)
Keep consistent logic for cancel suppression of a context
We already have helper.SuppressCancellation to suppress the cancel of a given context and keep context Values and everything else unchanged. So it is better to reuse that. Signed-off-by: blanet <moweng.xx@alibaba-inc.com>
-rw-r--r--internal/gitaly/service/hook/pack_objects.go16
1 files changed, 1 insertions, 15 deletions
diff --git a/internal/gitaly/service/hook/pack_objects.go b/internal/gitaly/service/hook/pack_objects.go
index ba7170989..f71db9d2c 100644
--- a/internal/gitaly/service/hook/pack_objects.go
+++ b/internal/gitaly/service/hook/pack_objects.go
@@ -105,20 +105,6 @@ func (s *server) packObjectsHook(ctx context.Context, repo *gitalypb.Repository,
return r.Wait(ctx)
}
-type contextWithoutCancel struct {
- context.Context
- valueCtx context.Context
-}
-
-func (cwc *contextWithoutCancel) Value(key interface{}) interface{} { return cwc.valueCtx.Value(key) }
-
-func cloneContextValues(ctx context.Context) context.Context {
- return &contextWithoutCancel{
- Context: context.Background(),
- valueCtx: ctx,
- }
-}
-
func (s *server) runPackObjects(ctx context.Context, w io.Writer, repo *gitalypb.Repository, args *packObjectsArgs, stdin io.ReadCloser, key string) error {
// We want to keep the context for logging, but we want to block all its
// cancelation signals (deadline, cancel etc.). This is because of
@@ -131,7 +117,7 @@ func (s *server) runPackObjects(ctx context.Context, w io.Writer, repo *gitalypb
// If the cancelation of client1 propagated into the runPackObjects
// goroutine this would affect client2. We don't want that. So to prevent
// that, we suppress the cancelation of the originating context.
- ctx = cloneContextValues(ctx)
+ ctx = helper.SuppressCancellation(ctx)
ctx, cancel := context.WithCancel(ctx)
defer cancel()