From 4344af6fd3ce4ff1bd975161b2df7e800d52f236 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Thu, 20 Oct 2022 11:11:45 +0530 Subject: [PATCH] Some misc changes (#1107) - ticker.Stop always - clean up timer func (if they are added) on participant close - sequencer test enhancement to add a real packet after a pdding packet --- pkg/rtc/config.go | 1 + pkg/rtc/participant.go | 3 +++ pkg/service/redisstore.go | 2 ++ pkg/sfu/sequencer_test.go | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/rtc/config.go b/pkg/rtc/config.go index bd08a5df9..78af305fe 100644 --- a/pkg/rtc/config.go +++ b/pkg/rtc/config.go @@ -329,6 +329,7 @@ func getNAT1to1IPsForConf(conf *config.Config) ([]string, error) { var firstResloved bool natMapping := make(map[string]string) timeout := time.NewTimer(5 * time.Second) + defer timeout.Stop() done: for { diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 92eccb2ac..2b660055c 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -524,6 +524,9 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea return nil } + p.clearDisconnectTimer() + p.clearMigrationTimer() + // send leave message if sendLeave { _ = p.writeMessage(&livekit.SignalResponse{ diff --git a/pkg/service/redisstore.go b/pkg/service/redisstore.go index 4d5c366f5..8835ad64a 100644 --- a/pkg/service/redisstore.go +++ b/pkg/service/redisstore.go @@ -420,6 +420,8 @@ func (s *RedisStore) UpdateEgress(_ context.Context, info *livekit.EgressInfo) e // Deletes egress info 24h after the egress has ended func (s *RedisStore) egressWorker() { ticker := time.NewTicker(time.Minute * 30) + defer ticker.Stop() + for { select { case <-s.done: diff --git a/pkg/sfu/sequencer_test.go b/pkg/sfu/sequencer_test.go index 5156b0bee..8a3eb0644 100644 --- a/pkg/sfu/sequencer_test.go +++ b/pkg/sfu/sequencer_test.go @@ -71,14 +71,14 @@ func Test_sequencer_getNACKSeqNo(t *testing.T) { { name: "Should get correct seq numbers", fields: fields{ - input: []uint16{2, 3, 4, 7, 8}, + input: []uint16{2, 3, 4, 7, 8, 11}, padding: []uint16{9, 10}, offset: 5, }, args: args{ - seqNo: []uint16{4 + 5, 5 + 5, 8 + 5, 9 + 5, 10 + 5}, + seqNo: []uint16{4 + 5, 5 + 5, 8 + 5, 9 + 5, 10 + 5, 11 + 5}, }, - want: []uint16{4, 8}, + want: []uint16{4, 8, 11}, }, } for _, tt := range tests {