From 47a975de09c1b9829f61a4af94d6475c7b47b9d4 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:07:37 +0100 Subject: [PATCH] hls: fix race condition --- internal/hls/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/hls/client.go b/internal/hls/client.go index 42b13d3a..2f6c45f2 100644 --- a/internal/hls/client.go +++ b/internal/hls/client.go @@ -100,10 +100,11 @@ func (q *clientSegmentQueue) waitAndPull(ctx context.Context) ([]byte, error) { q.mutex.Lock() for len(q.queue) == 0 { + didPush := q.didPush q.mutex.Unlock() select { - case <-q.didPush: + case <-didPush: case <-ctx.Done(): return nil, fmt.Errorf("terminated") }