TUN-5530: Get current time from ticker

This commit is contained in:
cthuang 2021-12-13 13:35:40 +00:00
parent b0e27d1eac
commit 9251b3aa1f
1 changed files with 3 additions and 2 deletions

View File

@ -77,9 +77,10 @@ func (s *Session) waitForCloseCondition(ctx context.Context, closeAfterIdle time
return return
case <-s.doneChan: case <-s.doneChan:
return return
case <-checkIdleTicker.C: // TODO: TUN-5423 evaluate if using atomic is more efficient
case now := <-checkIdleTicker.C:
// The session is considered inactive if current time is after (last active time + allowed idle time) // The session is considered inactive if current time is after (last active time + allowed idle time)
if time.Now().After(activeAt.Add(closeAfterIdle)) { if now.After(activeAt.Add(closeAfterIdle)) {
return return
} }
case activeAt = <-s.activeAtChan: // Update last active time case activeAt = <-s.activeAtChan: // Update last active time