]> 127.0.0.1 Git - part/.git/commitdiff
add v0.28.0+2023060218588d4
authorqydysky <qydysky@foxmail.com>
Fri, 2 Jun 2023 19:55:08 +0000 (03:55 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 2 Jun 2023 19:55:08 +0000 (03:55 +0800)
reqf/Reqf.go

index f3c98185e77f5dd7ddacd615907de83812d10ade..707cea7e47ecaa678847367e1c7e59caa01b85f4 100644 (file)
@@ -405,8 +405,16 @@ func (t *Req) withCtxTO(ctx context.Context, to time.Duration, w io.Writer, r io
                for {
                        select {
                        case <-ctx.Done():
-                               if chanw.Load() != 0 {
-                                       panic(fmt.Sprintf("write blocking after Ctx Done, goruntime leak \n%v", callTree))
+                               if old, now := chanw.Load(), time.Now(); old != 0 && now.Unix()-old > int64(to.Seconds()) {
+                                       if chanw.Load() != 0 {
+                                               panic(fmt.Sprintf("write blocking after %v, goruntime leak \n%v", now.Unix()-old, callTree))
+                                       }
+                               } else {
+                                       time.AfterFunc(to, func() {
+                                               if chanw.Load() != 0 {
+                                                       panic(fmt.Sprintf("write blocking after %v, goruntime leak \n%v", now.Unix()-old, callTree))
+                                               }
+                                       })
                                }
                                return
                        case now := <-timer.C: