From cc86db60fc6427b12572b2dbcf789d8c0ed6656e Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Fri, 19 Jan 2024 21:29:31 -0500 Subject: [PATCH] mls: remove unecessary passive ticker from subscribe --- pkg/mls/api/v1/service.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/mls/api/v1/service.go b/pkg/mls/api/v1/service.go index 7fcdcb68..62413e2b 100644 --- a/pkg/mls/api/v1/service.go +++ b/pkg/mls/api/v1/service.go @@ -412,19 +412,15 @@ func (s *Service) SubscribeGroupMessages(req *mlsv1.SubscribeGroupMessagesReques } } - activeTicker := time.NewTicker(100 * time.Millisecond) - defer activeTicker.Stop() - passiveTicker := time.NewTicker(5 * time.Second) - defer passiveTicker.Stop() + ticker := time.NewTicker(200 * time.Millisecond) + defer ticker.Stop() for { select { case <-stream.Context().Done(): return case <-s.ctx.Done(): return - case <-passiveTicker.C: - setHasMessages() - case <-activeTicker.C: + case <-ticker.C: var skip bool func() { hasMessagesLock.Lock() @@ -545,19 +541,15 @@ func (s *Service) SubscribeWelcomeMessages(req *mlsv1.SubscribeWelcomeMessagesRe } } - activeTicker := time.NewTicker(200 * time.Millisecond) - defer activeTicker.Stop() - passiveTicker := time.NewTicker(5 * time.Second) - defer passiveTicker.Stop() + ticker := time.NewTicker(200 * time.Millisecond) + defer ticker.Stop() for { select { case <-stream.Context().Done(): return case <-s.ctx.Done(): return - case <-passiveTicker.C: - setHasMessages() - case <-activeTicker.C: + case <-ticker.C: var skip bool func() { hasMessagesLock.Lock()