Browse Source

common: fix task leak in timer (#4831)

signal包里面SetTimeout方法并发时可能会出现task close以后执行start导致泄露
isluckys 4 months ago
parent
commit
cb1afb33e6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      common/signal/timer.go

+ 1 - 1
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 {