From: qydysky Date: Sun, 4 Jun 2023 23:15:58 +0000 (+0800) Subject: add X-Git-Tag: v0.28.0+20230604bee01ff X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=bee01ff2fde7a2c6c6d3a4a026a2f1d892034e91;p=part%2F.git add --- diff --git a/io/io.go b/io/io.go index 9ea6d52..1bfc7c4 100644 --- a/io/io.go +++ b/io/io.go @@ -76,12 +76,12 @@ func WithCtxTO(ctx context.Context, callTree string, to time.Duration, w io.Writ for { select { case <-ctx.Done(): - if old, now := chanw.Load(), time.Now(); old > 0 && now.Unix()-old > int64(to.Seconds()) { + if old := chanw.Load(); old < 0 { + return + } else if now := time.Now(); old > 0 && now.Unix()-old > int64(to.Seconds()) { if old != 0 { panicf[0](fmt.Sprintf("write blocking while close %vs > %v, goruntime leak \n%v", now.Unix()-old, to, callTree)) } - } else if old < 0 { - return } else { time.AfterFunc(to, func() { if old, now := chanw.Load(), time.Now(); old != 0 && now.Unix()-old > int64(to.Seconds()) { @@ -91,10 +91,10 @@ func WithCtxTO(ctx context.Context, callTree string, to time.Duration, w io.Writ } return case now := <-timer.C: - if old := chanw.Load(); old > 0 && now.Unix()-old > int64(to.Seconds()) { - panicf[0](fmt.Sprintf("write blocking after rw %vs > %v, goruntime leak \n%v", now.Unix()-old, to, callTree)) + if old := chanw.Load(); old < 0 { return - } else if old < 0 { + } else if old > 0 && now.Unix()-old > int64(to.Seconds()) { + panicf[0](fmt.Sprintf("write blocking after rw %vs > %v, goruntime leak \n%v", now.Unix()-old, to, callTree)) return } }