From ea8f7e750645e0e9d9507e7672cef7c3ddcf2c93 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 4 Jun 2016 19:59:23 +0200 Subject: [PATCH] simpilify updateUserHash method --- common/protocol/user_validator.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/protocol/user_validator.go b/common/protocol/user_validator.go index 59b871a4b..a63ace83a 100644 --- a/common/protocol/user_validator.go +++ b/common/protocol/user_validator.go @@ -50,7 +50,7 @@ func NewTimedUserValidator(hasher IDHash) UserValidator { hasher: hasher, cancel: signal.NewCloseSignal(), } - go tus.updateUserHash(updateIntervalSec*time.Second, tus.cancel) + go tus.updateUserHash(updateIntervalSec * time.Second) return tus } @@ -88,7 +88,7 @@ func (this *TimedUserValidator) generateNewHashes(nowSec Timestamp, idx int, ent } } -func (this *TimedUserValidator) updateUserHash(interval time.Duration, cancel *signal.CancelSignal) { +func (this *TimedUserValidator) updateUserHash(interval time.Duration) { L: for { select { @@ -97,11 +97,11 @@ L: for _, entry := range this.ids { this.generateNewHashes(nowSec, entry.userIdx, entry) } - case <-cancel.WaitForCancel(): + case <-this.cancel.WaitForCancel(): break L } } - cancel.Done() + this.cancel.Done() } func (this *TimedUserValidator) Add(user *User) error {