Skip to content

rtsp-stream: avoid deadlock in send_func

Currently the send_func() runs in a thread of its own which is started the first time we enter handle_new_sample(). It runs in an outer loop until priv->continue_sending is FALSE, which happens when a TEARDOWN request is received. We use a local variable, cont, which is initialized to TRUE, meaning that we will always enter the outer loop, and at the end of the outer loop we assign it the value of priv->continue_sending.

Within the outer loop there is an inner loop, where we wait to be signaled when there is more data to send. The inner loop is exited when priv->send_cookie has changed value, which it does when more data is available or when a TEARDOWN has been received.

But if we get a TEARDOWN before send_func() is entered we will get stuck in the inner loop because no one will increase priv->session_cookie anymore.

By not entering the outer loop in send_func() if priv->continue_sending is FALSE we make sure that we do not get stuck in send_func()'s inner loop should we receive a TEARDOWN before the send thread has started.

Merge request reports