Skip to content

Commit 20b88c2

Browse files
authored
Speedup session start when SessionTime isn't set.
Added a check to skip sleeping to speedup session start for sessions without start and stop times.
1 parent 9c57408 commit 20b88c2

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

session.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -906,14 +906,16 @@ func (s *session) run() {
906906
}
907907

908908
})
909-
910-
// Without this sleep the ticker will be aligned at the millisecond which
911-
// corresponds to the creation of the session. If the session creation
912-
// happened at 07:00:00.678 and the session StartTime is 07:30:00, any new
913-
// connection received between 07:30:00.000 and 07:30:00.677 will be
914-
// rejected. Aligning the ticker with a round second fixes that.
915-
time.Sleep(time.Until(time.Now().Truncate(time.Second).Add(time.Second)))
916-
909+
910+
if s.SessionTime != nil {
911+
// Without this sleep the ticker will be aligned at the millisecond which
912+
// corresponds to the creation of the session. If the session creation
913+
// happened at 07:00:00.678 and the session StartTime is 07:30:00, any new
914+
// connection received between 07:30:00.000 and 07:30:00.677 will be
915+
// rejected. Aligning the ticker with a round second fixes that.
916+
time.Sleep(time.Until(time.Now().Truncate(time.Second).Add(time.Second)))
917+
}
918+
917919
ticker := time.NewTicker(time.Second)
918920

919921
defer func() {

0 commit comments

Comments
 (0)