From 0bf994f0cafdd586d7592d0de41c12f4e1bb100c Mon Sep 17 00:00:00 2001 From: David Colburn Date: Mon, 2 Oct 2023 12:31:27 -0700 Subject: [PATCH] tighten locking --- pkg/pipeline/sink/segments.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/pipeline/sink/segments.go b/pkg/pipeline/sink/segments.go index 902c503e..57413929 100644 --- a/pkg/pipeline/sink/segments.go +++ b/pkg/pipeline/sink/segments.go @@ -155,13 +155,13 @@ func (s *SegmentSink) handleClosedSegment(update SegmentUpdate) { func (s *SegmentSink) handlePlaylistUpdates(update SegmentUpdate) error { s.segmentLock.Lock() - defer s.segmentLock.Unlock() - t, ok := s.openSegmentsStartTime[update.filename] if !ok { + s.segmentLock.Unlock() return fmt.Errorf("no open segment with the name %s", update.filename) } delete(s.openSegmentsStartTime, update.filename) + s.segmentLock.Unlock() duration := float64(time.Duration(update.endTime-t)) / float64(time.Second) segmentStartTime := s.startTime.Add(time.Duration(t - s.startRunningTime)) @@ -180,6 +180,7 @@ func (s *SegmentSink) handlePlaylistUpdates(update SegmentUpdate) error { return err } } + s.playlistLock.Unlock() // throttle playlist uploads s.throttle(func() {