]> 127.0.0.1 Git - part/.git/commitdiff
1
authorqydysky <qydysky@foxmail.com>
Sat, 23 Mar 2024 21:12:45 +0000 (05:12 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 23 Mar 2024 21:12:45 +0000 (05:12 +0800)
reqf/Reqf.go

index 243504ebc2a45c40dc3787e24d48521480581090..772c1b0d89c703f153262913589f7c4e30de7a7f 100644 (file)
@@ -272,10 +272,18 @@ func (t *Req) reqf(ctx context.Context, val Rval) (err error) {
        }
 
        // io copy
-       var panicf = func(s string) {
-               err = errors.Join(err, errors.New(s))
+       errChan := make(chan error, 3)
+       errChan <- pio.WithCtxCopy(
+               req.Context(),
+               t.callTree,
+               t.copyResBuf[:],
+               time.Duration(int(time.Millisecond)*writeLoopTO), io.MultiWriter(ws...),
+               resReadCloser,
+               func(s string) { errChan <- errors.New(s) },
+       )
+       for len(errChan) > 0 {
+               err = errors.Join(err, <-errChan)
        }
-       err = errors.Join(err, pio.WithCtxCopy(req.Context(), t.callTree, t.copyResBuf[:], time.Duration(int(time.Millisecond)*writeLoopTO), io.MultiWriter(ws...), resReadCloser, panicf))
 
        if t.responBuf != nil {
                t.Respon = t.responBuf.Bytes()