From 50ac9db27496c7f6e9ebaeb24b25fa7be16588e6 Mon Sep 17 00:00:00 2001 From: Khoi Van Nguyen Date: Mon, 23 Dec 2024 14:44:51 +0700 Subject: [PATCH] Fix: receive hang indefinitely After writing the first bytes from buffer, it doesn't "notify" the reader and continue to write to the buffer without knowing buffer is consume entirely or not. The reader hence can send wrong data to receiver. With incorrect box size, it can hang forever. `testpic` segment size is small (<65536), so it is not affected. --- cmd/livesim2/app/cmaf-ingester.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/livesim2/app/cmaf-ingester.go b/cmd/livesim2/app/cmaf-ingester.go index 43f1b37..8cf9e3c 100644 --- a/cmd/livesim2/app/cmaf-ingester.go +++ b/cmd/livesim2/app/cmaf-ingester.go @@ -683,6 +683,7 @@ func (cs *cmafSource) Write(b []byte) (int, error) { if nrWritten == len(b) { break } + <-cs.writeMoreCh } return len(b), nil }