From: qydysky Date: Tue, 8 Aug 2023 18:41:21 +0000 (+0800) Subject: add X-Git-Tag: v0.28.0+202308089caa551 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=9caa5514df96f542c7c36d7da9e24ea29f9737a2;p=part%2F.git add --- diff --git a/reqf/Reqf.go b/reqf/Reqf.go index 39a7e02..77d15a7 100644 --- a/reqf/Reqf.go +++ b/reqf/Reqf.go @@ -81,7 +81,8 @@ type Req struct { err error callTree string - l sync.RWMutex + copyResBuf []byte + l sync.RWMutex } func New() *Req { @@ -273,7 +274,7 @@ func (t *Req) Reqf_1(ctx context.Context, val Rval) (err error) { var panicf = func(s string) { err = errors.Join(err, errors.New(s)) } - err = errors.Join(err, pio.WithCtxCopy(req.Context(), t.callTree, time.Duration(int(time.Millisecond)*writeLoopTO), io.MultiWriter(ws...), resReadCloser, panicf)) + err = errors.Join(err, pio.WithCtxCopy(req.Context(), t.callTree, t.copyResBuf[:], time.Duration(int(time.Millisecond)*writeLoopTO), io.MultiWriter(ws...), resReadCloser, panicf)) resp.Body.Close() @@ -336,6 +337,9 @@ func (t *Req) prepare(val *Rval) (ctx context.Context, cancel context.CancelFunc t.callTree += fmt.Sprintf("call by %s\n\t%s:%d\n", runtime.FuncForPC(pc).Name(), file, line) } } + if cap(t.copyResBuf) == 0 { + t.copyResBuf = make([]byte, 1<<17) + } if val.Ctx != nil { ctx, cancel = context.WithCancel(val.Ctx) } else {