From 58d1b579625ed4e7546e634d1e4e55b7279e36fe Mon Sep 17 00:00:00 2001 From: qydysky Date: Tue, 6 Jun 2023 18:52:48 +0800 Subject: [PATCH] fix --- io/io.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/io/io.go b/io/io.go index 1bfc7c4..c1ad7b6 100644 --- a/io/io.go +++ b/io/io.go @@ -76,7 +76,7 @@ func WithCtxTO(ctx context.Context, callTree string, to time.Duration, w io.Writ for { select { case <-ctx.Done(): - if old := chanw.Load(); old < 0 { + if old := chanw.Load(); old == -1 { return } else if now := time.Now(); old > 0 && now.Unix()-old > int64(to.Seconds()) { if old != 0 { @@ -84,14 +84,16 @@ func WithCtxTO(ctx context.Context, callTree string, to time.Duration, w io.Writ } } else { time.AfterFunc(to, func() { - if old, now := chanw.Load(), time.Now(); old != 0 && now.Unix()-old > int64(to.Seconds()) { + if old := chanw.Load(); old == -1 { + return + } else if now := time.Now(); old > 0 && now.Unix()-old > int64(to.Seconds()) { panicf[0](fmt.Sprintf("write blocking after close %vs > %v, goruntime leak \n%v", now.Unix()-old, to, callTree)) } }) } return case now := <-timer.C: - if old := chanw.Load(); old < 0 { + if old := chanw.Load(); old == -1 { return } 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)) -- 2.39.2