mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
fix race condition in ActivityTimer
This commit is contained in:
parent
57d6808882
commit
ef4542e778
@ -56,18 +56,20 @@ func (t *ActivityTimer) SetTimeout(timeout time.Duration) {
|
||||
return
|
||||
}
|
||||
|
||||
checkTask := &task.Periodic{
|
||||
Interval: timeout,
|
||||
Execute: t.check,
|
||||
}
|
||||
|
||||
t.Lock()
|
||||
|
||||
if t.checkTask != nil {
|
||||
t.checkTask.Close() // nolint: errcheck
|
||||
}
|
||||
t.checkTask = &task.Periodic{
|
||||
Interval: timeout,
|
||||
Execute: t.check,
|
||||
}
|
||||
t.checkTask = checkTask
|
||||
t.Unlock()
|
||||
t.Update()
|
||||
common.Must(t.checkTask.Start())
|
||||
common.Must(checkTask.Start())
|
||||
}
|
||||
|
||||
func CancelAfterInactivity(ctx context.Context, cancel context.CancelFunc, timeout time.Duration) *ActivityTimer {
|
||||
|
Loading…
Reference in New Issue
Block a user