From 6920f44408a7d952834e795cd20e06ac0d6645e8 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 7 Jan 2024 16:39:20 +0800 Subject: [PATCH] 1 --- web/Web.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/web/Web.go b/web/Web.go index d18a438..60c8b66 100644 --- a/web/Web.go +++ b/web/Web.go @@ -478,22 +478,22 @@ func (t *Exprier) Check(key string) error { return nil } -func (t *Exprier) LoopCheck(key string, checkDru time.Duration, conn net.Conn) (done func()) { +func (t *Exprier) LoopCheck(key string, checkDru time.Duration, whenfail func()) (done func(), e error) { if t.max <= 0 { - return func() {} + return func() {}, nil } if key == "" { - conn.Close() - return func() {} + whenfail() + return func() {}, ErrNoFound } ey, ok := t.m.LoadV(key).(time.Time) if !ok { - conn.Close() - return func() {} + whenfail() + return func() {}, ErrNoFound } else if time.Now().After(ey) { t.m.Delete(key) - conn.Close() - return func() {} + whenfail() + return func() {}, ErrExprie } c := make(chan struct{}) @@ -501,10 +501,12 @@ func (t *Exprier) LoopCheck(key string, checkDru time.Duration, conn net.Conn) ( for t.max > 0 { ey, ok := t.m.LoadV(key).(time.Time) if !ok { - conn.Close() + whenfail() + return } else if time.Now().After(ey) { t.m.Delete(key) - conn.Close() + whenfail() + return } select { case <-c: @@ -515,7 +517,7 @@ func (t *Exprier) LoopCheck(key string, checkDru time.Duration, conn net.Conn) ( }() return func() { close(c) - } + }, nil } func (t *Exprier) Disable() { -- 2.39.2