Skip to content

Commit 3e41031

Browse files
authored
Merge pull request #533 from sylr/align-session-ticker
Align session's ticker with round second
2 parents c83230c + 2dad0f0 commit 3e41031

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

session.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,14 @@ func (s *session) run() {
758758
}
759759

760760
})
761+
762+
// Without this sleep the ticker will be aligned at the millisecond which
763+
// corresponds to the creation of the session. If the session creation
764+
// happened at 07:00:00.678 and the session StartTime is 07:30:00, any new
765+
// connection received between 07:30:00.000 and 07:30:00.677 will be
766+
// rejected. Aligning the ticker with a round second fixes that.
767+
time.Sleep(time.Until(time.Now().Truncate(time.Second).Add(time.Second)))
768+
761769
ticker := time.NewTicker(time.Second)
762770

763771
defer func() {

0 commit comments

Comments
 (0)