From 20b88c2faeaccf25f3da0d8922e31f7f801db9ba Mon Sep 17 00:00:00 2001 From: Kajonn Date: Mon, 12 Jan 2026 15:13:10 +0100 Subject: [PATCH 1/2] 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. --- session.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/session.go b/session.go index 342988f64..4ad008745 100644 --- a/session.go +++ b/session.go @@ -906,14 +906,16 @@ func (s *session) run() { } }) - - // Without this sleep the ticker will be aligned at the millisecond which - // corresponds to the creation of the session. If the session creation - // happened at 07:00:00.678 and the session StartTime is 07:30:00, any new - // connection received between 07:30:00.000 and 07:30:00.677 will be - // rejected. Aligning the ticker with a round second fixes that. - time.Sleep(time.Until(time.Now().Truncate(time.Second).Add(time.Second))) - + + if s.SessionTime != nil { + // Without this sleep the ticker will be aligned at the millisecond which + // corresponds to the creation of the session. If the session creation + // happened at 07:00:00.678 and the session StartTime is 07:30:00, any new + // connection received between 07:30:00.000 and 07:30:00.677 will be + // rejected. Aligning the ticker with a round second fixes that. + time.Sleep(time.Until(time.Now().Truncate(time.Second).Add(time.Second))) + } + ticker := time.NewTicker(time.Second) defer func() { From 012919aa511fda6f90afe304059c8c58f05dbaf4 Mon Sep 17 00:00:00 2001 From: Kajonn Date: Mon, 12 Jan 2026 15:55:26 +0100 Subject: [PATCH 2/2] Format --- session.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/session.go b/session.go index 4ad008745..83a3bd4a3 100644 --- a/session.go +++ b/session.go @@ -906,7 +906,7 @@ func (s *session) run() { } }) - + if s.SessionTime != nil { // Without this sleep the ticker will be aligned at the millisecond which // corresponds to the creation of the session. If the session creation @@ -915,7 +915,7 @@ func (s *session) run() { // rejected. Aligning the ticker with a round second fixes that. time.Sleep(time.Until(time.Now().Truncate(time.Second).Add(time.Second))) } - + ticker := time.NewTicker(time.Second) defer func() {