Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsannm committed May 12, 2022
1 parent 41b7c90 commit ae6b29c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type (
type Context struct {
utils.SpinLock
ctx context.Context //nolint:containedctx
cf func()

kv map[string]interface{}
hdr map[string]string
Expand Down Expand Up @@ -87,7 +88,7 @@ func (ctx *Context) SetUserContext(userCtx context.Context) {
func (ctx *Context) Context() context.Context {
ctx.Lock()
if ctx.ctx == nil {
ctx.ctx = context.Background()
ctx.ctx, ctx.cf = context.WithCancel(context.Background())
}
ctx.Unlock()

Expand Down Expand Up @@ -191,6 +192,11 @@ func (ctx *Context) reset() {
ctx.handlerIndex = 0
ctx.handlers = ctx.handlers[:0]
ctx.modifiers = ctx.modifiers[:0]
if ctx.cf != nil {
ctx.cf()
ctx.cf = nil
}
ctx.ctx = nil
}

type ctxPool struct {
Expand Down

0 comments on commit ae6b29c

Please sign in to comment.