Skip to content

Commit 2dad0f0

Browse files
sylrAlexm126
andcommitted
Align session's ticker with round second
Co-authored-by: Alexis Masson <[email protected]> Signed-off-by: Sylvain Rabot <[email protected]>
1 parent 04aa323 commit 2dad0f0

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
@@ -754,6 +754,14 @@ func (s *session) run() {
754754
}
755755

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

759767
defer func() {

0 commit comments

Comments
 (0)