Skip to content

Commit

Permalink
tighten locking
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed Oct 2, 2023
1 parent de74bd7 commit 0bf994f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/pipeline/sink/segments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -180,6 +180,7 @@ func (s *SegmentSink) handlePlaylistUpdates(update SegmentUpdate) error {
return err
}
}
s.playlistLock.Unlock()

// throttle playlist uploads
s.throttle(func() {
Expand Down

0 comments on commit 0bf994f

Please sign in to comment.