mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
rtmp2: Avoid a deadlock when getting stats
We need to do this without holding the lock as the `g_async_queue_pop` waits on the loop thread to deliver the stats. The loop thread might attempt to take the lock as well, leading to a deadlock. Taking a reference to the connection should be enough to keep this safe.
This commit is contained in:
parent
be8cec5348
commit
6680b70781
2 changed files with 24 additions and 2 deletions
|
@ -1144,7 +1144,18 @@ gst_rtmp2_sink_get_stats (GstRtmp2Sink * self)
|
||||||
g_mutex_lock (&self->lock);
|
g_mutex_lock (&self->lock);
|
||||||
|
|
||||||
if (self->connection) {
|
if (self->connection) {
|
||||||
s = gst_rtmp_connection_get_stats (self->connection);
|
GstRtmpConnection *connection = g_object_ref (self->connection);
|
||||||
|
|
||||||
|
g_mutex_unlock (&self->lock);
|
||||||
|
|
||||||
|
/* We need to do this without holding the lock as the g_async_queue_pop
|
||||||
|
* waits on the loop thread to deliver the stats. The loop thread might
|
||||||
|
* attempt to take the lock as well, leading to a deadlock. */
|
||||||
|
s = gst_rtmp_connection_get_stats (connection);
|
||||||
|
|
||||||
|
g_mutex_lock (&self->lock);
|
||||||
|
|
||||||
|
g_object_unref (connection);
|
||||||
} else if (self->stats) {
|
} else if (self->stats) {
|
||||||
s = gst_structure_copy (self->stats);
|
s = gst_structure_copy (self->stats);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -979,7 +979,18 @@ gst_rtmp2_src_get_stats (GstRtmp2Src * self)
|
||||||
g_mutex_lock (&self->lock);
|
g_mutex_lock (&self->lock);
|
||||||
|
|
||||||
if (self->connection) {
|
if (self->connection) {
|
||||||
s = gst_rtmp_connection_get_stats (self->connection);
|
GstRtmpConnection *connection = g_object_ref (self->connection);
|
||||||
|
|
||||||
|
g_mutex_unlock (&self->lock);
|
||||||
|
|
||||||
|
/* We need to do this without holding the lock as the g_async_queue_pop
|
||||||
|
* waits on the loop thread to deliver the stats. The loop thread might
|
||||||
|
* attempt to take the lock as well, leading to a deadlock. */
|
||||||
|
s = gst_rtmp_connection_get_stats (connection);
|
||||||
|
|
||||||
|
g_mutex_lock (&self->lock);
|
||||||
|
|
||||||
|
g_object_unref (connection);
|
||||||
} else if (self->stats) {
|
} else if (self->stats) {
|
||||||
s = gst_structure_copy (self->stats);
|
s = gst_structure_copy (self->stats);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue