Skip to content

Commit

Permalink
streamer: don't double lock the streamer mutex in Stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed May 29, 2024
1 parent bc427e7 commit 9448b80
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions streamer/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,8 @@ func (s *Streamer) Stop(ctx context.Context, force bool) error {
const op errors.Op = "streamer/Streamer.Stop"

s.mu.Lock()
defer s.mu.Unlock()

if !s.running {
s.mu.Unlock()
// we're not even running
return errors.E(op, errors.StreamerNotRunning)
}
Expand All @@ -327,13 +326,15 @@ func (s *Streamer) Stop(ctx context.Context, force bool) error {
// flag that is checked in all the loops we run
s.cancel(ErrForce)
s.forced.Store(true)
s.mu.Unlock()
return s.Wait(ctx)
}

// #2 is a normal stop, this will exit once the current song ends, we achieve this
// by stopping the encoder and then waiting for the icecast to notice the input
// channel to have been closed
s.encoderCancel()
s.mu.Unlock()
return s.Wait(ctx)
}

Expand Down

0 comments on commit 9448b80

Please sign in to comment.