diff --git a/session.go b/session.go index 342988f64..83a3bd4a3 100644 --- a/session.go +++ b/session.go @@ -907,12 +907,14 @@ 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)