From cb1afb33e68c56bf4510ad658ab86a0468b8c36c Mon Sep 17 00:00:00 2001 From: isluckys <152280768+isluckys@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:47:27 +0800 Subject: [PATCH] common: fix task leak in timer (#4831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit signal包里面SetTimeout方法并发时可能会出现task close以后执行start导致泄露 --- common/signal/timer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/signal/timer.go b/common/signal/timer.go index a7f59cd9..ece9f496 100644 --- a/common/signal/timer.go +++ b/common/signal/timer.go @@ -67,9 +67,9 @@ func (t *ActivityTimer) SetTimeout(timeout time.Duration) { t.checkTask.Close() } t.checkTask = checkTask - t.Unlock() t.Update() common.Must(checkTask.Start()) + t.Unlock() } func CancelAfterInactivity(ctx context.Context, cancel context.CancelFunc, timeout time.Duration) *ActivityTimer {