1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-07-05 16:38:17 -04:00

close timer sooner

This commit is contained in:
Darien Raymond 2017-01-31 12:54:01 +01:00
parent c462e35aad
commit 23a8da215f
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -21,14 +21,21 @@ func (t *ActivityTimer) UpdateActivity() {
func (t *ActivityTimer) run() {
for {
time.Sleep(t.timeout)
select {
case <-t.ctx.Done():
return
case <-t.updated:
default:
case <-time.After(t.timeout):
t.cancel()
return
case <-t.ctx.Done():
return
default:
select {
case <-time.After(t.timeout):
t.cancel()
return
case <-t.ctx.Done():
return
case <-t.updated:
}
}
}
}