1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-29 05:25:21 -05:00

close timer sooner

This commit is contained in:
Darien Raymond
2017-01-31 12:54:01 +01:00
parent c462e35aad
commit 23a8da215f

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:
}
}
}
}