From 706d91371c7257db7f7906cd9fc6e6ea0a2dd3af Mon Sep 17 00:00:00 2001 From: Tobias Ronge Date: Mon, 7 Dec 2020 10:01:53 +0100 Subject: [PATCH] rtspsrc: Do not wait for response while flushing Due to the may_cancel flag in GstRTSPConnection, receiving might not get cancelled when supposed to. In this case, gst_rtsp_src_receive_response will have to wait until timeout instead but if busy receiving RTP data, this timeout will never occur. With this patch, gst_rtsp_src_receive_response returns GST_RTSP_EINTR if flushing is set to TRUE instead of continuing to receive. Part-of: --- gst/rtsp/gstrtspsrc.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index dd871c975b..bf5b72f02a 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -5596,11 +5596,15 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src) while (TRUE) { gst_rtsp_message_unset (&message); - /* protect the connection with the connection lock so that we can see when - * we are finished doing server communication */ - res = - gst_rtspsrc_connection_receive (src, &src->conninfo, - &message, src->tcp_timeout); + if (src->conninfo.flushing) { + /* do not attempt to receive if flushing */ + res = GST_RTSP_EINTR; + } else { + /* protect the connection with the connection lock so that we can see when + * we are finished doing server communication */ + res = gst_rtspsrc_connection_receive (src, &src->conninfo, &message, + src->tcp_timeout); + } switch (res) { case GST_RTSP_OK: @@ -5715,8 +5719,13 @@ gst_rtspsrc_loop_udp (GstRTSPSrc * src) /* we should continue reading the TCP socket because the server might * send us requests. When the session timeout expires, we need to send a * keep-alive request to keep the session open. */ - res = gst_rtspsrc_connection_receive (src, &src->conninfo, &message, - timeout); + if (src->conninfo.flushing) { + /* do not attempt to receive if flushing */ + res = GST_RTSP_EINTR; + } else { + res = gst_rtspsrc_connection_receive (src, &src->conninfo, &message, + timeout); + } switch (res) { case GST_RTSP_OK: @@ -6363,8 +6372,13 @@ gst_rtsp_src_receive_response (GstRTSPSrc * src, GstRTSPConnInfo * conninfo, GstRTSPResult res; next: - res = gst_rtspsrc_connection_receive (src, conninfo, response, - src->tcp_timeout); + if (conninfo->flushing) { + /* do not attempt to receive if flushing */ + res = GST_RTSP_EINTR; + } else { + res = gst_rtspsrc_connection_receive (src, conninfo, response, + src->tcp_timeout); + } if (res < 0) goto receive_error;