mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
rtspconnection: Protect readsrc, writesrc and controllsrc with a mutex
Fixes a crash when controlsrc, readsrc or writesrc are modified from gst_rtsp_source_dispatch_read/write and gst_rtsp_watch_reset at the same time. https://bugzilla.gnome.org/show_bug.cgi?id=735569
This commit is contained in:
parent
2434af3d31
commit
acdb7feacf
1 changed files with 6 additions and 0 deletions
|
@ -3127,6 +3127,7 @@ gst_rtsp_source_dispatch_read (GPollableInputStream * stream,
|
||||||
if (res == GST_RTSP_EINTR)
|
if (res == GST_RTSP_EINTR)
|
||||||
goto done;
|
goto done;
|
||||||
else if (G_UNLIKELY (res == GST_RTSP_EEOF)) {
|
else if (G_UNLIKELY (res == GST_RTSP_EEOF)) {
|
||||||
|
g_mutex_lock (&watch->mutex);
|
||||||
if (watch->readsrc) {
|
if (watch->readsrc) {
|
||||||
g_source_remove_child_source ((GSource *) watch, watch->readsrc);
|
g_source_remove_child_source ((GSource *) watch, watch->readsrc);
|
||||||
g_source_unref (watch->readsrc);
|
g_source_unref (watch->readsrc);
|
||||||
|
@ -3139,6 +3140,7 @@ gst_rtsp_source_dispatch_read (GPollableInputStream * stream,
|
||||||
conn->socket1 = NULL;
|
conn->socket1 = NULL;
|
||||||
conn->input_stream = NULL;
|
conn->input_stream = NULL;
|
||||||
}
|
}
|
||||||
|
g_mutex_unlock (&watch->mutex);
|
||||||
|
|
||||||
/* When we are in tunnelled mode, the read socket can be closed and we
|
/* When we are in tunnelled mode, the read socket can be closed and we
|
||||||
* should be prepared for a new POST method to reopen it */
|
* should be prepared for a new POST method to reopen it */
|
||||||
|
@ -3150,6 +3152,7 @@ gst_rtsp_source_dispatch_read (GPollableInputStream * stream,
|
||||||
if (watch->funcs.tunnel_lost)
|
if (watch->funcs.tunnel_lost)
|
||||||
res = watch->funcs.tunnel_lost (watch, watch->user_data);
|
res = watch->funcs.tunnel_lost (watch, watch->user_data);
|
||||||
/* we add read source on the write socket able to detect when client closes get channel in tunneled mode */
|
/* we add read source on the write socket able to detect when client closes get channel in tunneled mode */
|
||||||
|
g_mutex_lock (&watch->mutex);
|
||||||
if (watch->conn->control_stream && !watch->controlsrc) {
|
if (watch->conn->control_stream && !watch->controlsrc) {
|
||||||
watch->controlsrc =
|
watch->controlsrc =
|
||||||
g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM
|
g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM
|
||||||
|
@ -3159,6 +3162,7 @@ gst_rtsp_source_dispatch_read (GPollableInputStream * stream,
|
||||||
NULL);
|
NULL);
|
||||||
g_source_add_child_source ((GSource *) watch, watch->controlsrc);
|
g_source_add_child_source ((GSource *) watch, watch->controlsrc);
|
||||||
}
|
}
|
||||||
|
g_mutex_unlock (&watch->mutex);
|
||||||
goto read_done;
|
goto read_done;
|
||||||
} else
|
} else
|
||||||
goto eof;
|
goto eof;
|
||||||
|
@ -3471,6 +3475,7 @@ gst_rtsp_watch_new (GstRTSPConnection * conn,
|
||||||
void
|
void
|
||||||
gst_rtsp_watch_reset (GstRTSPWatch * watch)
|
gst_rtsp_watch_reset (GstRTSPWatch * watch)
|
||||||
{
|
{
|
||||||
|
g_mutex_lock (&watch->mutex);
|
||||||
if (watch->readsrc) {
|
if (watch->readsrc) {
|
||||||
g_source_remove_child_source ((GSource *) watch, watch->readsrc);
|
g_source_remove_child_source ((GSource *) watch, watch->readsrc);
|
||||||
g_source_unref (watch->readsrc);
|
g_source_unref (watch->readsrc);
|
||||||
|
@ -3513,6 +3518,7 @@ gst_rtsp_watch_reset (GstRTSPWatch * watch)
|
||||||
} else {
|
} else {
|
||||||
watch->controlsrc = NULL;
|
watch->controlsrc = NULL;
|
||||||
}
|
}
|
||||||
|
g_mutex_unlock (&watch->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue