gstreamer/subprojects/gst-plugins-good/gst/rtpmanager
Scott Kanowitz 2e4fd325e7 rtpsession: fix a race condition during the EOS event in gstrtpsession.c
This patch prevents a possible race condition from taking place between the EOS event handling and rtcp send
function/thread.

The condition starts by getting the GST_EVENT_EOS event on the send_rtp_sink pad, which causes two core things
to happen -- the event gets pushed down to the send_rtp_src pad and all sessions get marked "bye" prior to
completion of the event handler. In another thread the rtp_session_on_timeout function gets called after an
expiration of gst_clock_id_wait in the rtcp_thread function. This results in a call to the
ess->callbacks.send_rtcp(), which is configured as a function pointer to gst_rtp_session_send_rtcp via the
RTPSessionCallbacks structure passed to rtp_session_set_callbacks in the gst_rtp_session_init function.

In the race condition, the call to gst_rtp_session_send_rtcp can have the all_sources_bye boolean set to true
while GST_PAD_IS_EOS(rtpsession->send_rtp_sink) evaluates to false. This is the result of gst_rtp_session_send_rtcp
running before the send_rtp_sink's GST_EVENT_EOS handler completes. The exact point at which this condition occurs
is if there's a context switch to the rtcp_thread right after the call to rtp_session_mark_all_bye in the
GET_EVENT_EOS handler, but before the handler returns.

Normally, this would not be an issue because the rtcp_thread continues to run and indirectly call
gst_rtp_session_send_rtcp. However, the call to rtp_source_reset sets the sent_bye boolean to false, which ends up
causing rtp_session_are_all_sources_bye to return false. This gets passed to gst_rtp_session_send_rtcp and the EOS
event never gets sent.

The race condition results in the EOS event never getting passed to the rtcp_src pad, which prevents the bin and
pipeline from ever completing with EOS.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3798>
2023-02-28 17:01:08 +00:00
..
gstrtpbin.c rtpsession: Support disabling late adjustment of ntp-64 header ext 2022-11-24 08:23:03 +00:00
gstrtpbin.h rtpsession: Support disabling late adjustment of ntp-64 header ext 2022-11-24 08:23:03 +00:00
gstrtpdtmfmux.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpdtmfmux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpfunnel.c rtpmanager: Move some duplicated constant and helper function to a single place 2022-04-20 14:40:25 +00:00
gstrtpfunnel.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtphdrext-clientaudiolevel.c rtphdrext-clientaudiolevel: Rename RFC 6464 element 2021-10-20 00:03:09 +00:00
gstrtphdrext-clientaudiolevel.h rtphdrext-clientaudiolevel: Rename RFC 6464 element 2021-10-20 00:03:09 +00:00
gstrtphdrext-mid.c rtpmanager: add support for writing RFC8843 (BUNDLE mid) RTP header extension 2022-03-21 03:18:18 +00:00
gstrtphdrext-mid.h rtpmanager: add support for writing RFC8843 (BUNDLE mid) RTP header extension 2022-03-21 03:18:18 +00:00
gstrtphdrext-ntp.c rtpmanager: Add header extension implementation for the 64-bit RFC6051 NTP header extension 2022-04-20 14:40:25 +00:00
gstrtphdrext-ntp.h rtpmanager: Add header extension implementation for the 64-bit RFC6051 NTP header extension 2022-04-20 14:40:25 +00:00
gstrtphdrext-repairedstreamid.c rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-repairedstreamid.h rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-streamid.c rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-streamid.h rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-twcc.c rtphdrext: Set caps without attributes as the default 2021-09-28 20:04:55 +00:00
gstrtphdrext-twcc.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpjitterbuffer.c rtpjitterbuffer: Reschedule timers when updating their offset 2022-11-16 08:26:41 +00:00
gstrtpjitterbuffer.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpmanager.c rtpmanager: Add header extension implementation for the 64-bit RFC6051 NTP header extension 2022-04-20 14:40:25 +00:00
gstrtpmux.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstrtpmux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpptdemux.c rtpptdemux: set different stream-id on each src pad 2023-02-01 09:17:33 +00:00
gstrtpptdemux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtprtxqueue.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtprtxqueue.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtprtxreceive.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstrtprtxreceive.h rtpmanager/rtx: implement initial support for reading/writing rid extensions 2022-03-21 03:18:18 +00:00
gstrtprtxsend.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstrtprtxsend.h rtpmanager/rtx: implement initial support for reading/writing rid extensions 2022-03-21 03:18:18 +00:00
gstrtpsession.c rtpsession: fix a race condition during the EOS event in gstrtpsession.c 2023-02-28 17:01:08 +00:00
gstrtpsession.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpssrcdemux.c rtpssrcdemux: set different stream-id on each src pad 2023-02-01 09:17:33 +00:00
gstrtpssrcdemux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpst2022-1-fecdec.c st2022-1-fecdec: fix packet trimming 2021-11-12 08:15:28 +00:00
gstrtpst2022-1-fecdec.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpst2022-1-fecenc.c rtpst2022-1-fecenc: Drain column packets on EOS 2022-08-12 12:59:19 +00:00
gstrtpst2022-1-fecenc.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtputils.c rtpmanager: Move some duplicated constant and helper function to a single place 2022-04-20 14:40:25 +00:00
gstrtputils.h rtpmanager: Move some duplicated constant and helper function to a single place 2022-04-20 14:40:25 +00:00
meson.build meson: Call pkgconfig.generate in the loop where we declare plugins dependencies 2022-09-01 21:17:35 +00:00
rtpjitterbuffer.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtpjitterbuffer.h rtpjitterbuffer: add "add-reference-timestamp-meta" property 2022-03-16 09:52:58 +00:00
rtpsession.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtpsession.h rtpsession: Support disabling late adjustment of ntp-64 header ext 2022-11-24 08:23:03 +00:00
rtpsource.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtpsource.h rtpsource: Don't do probation for RTX sources 2022-10-10 14:56:18 +00:00
rtpstats.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
rtpstats.h rtpsession: Update 64-bit NTP header extensions with the actual NTP time in senders 2022-04-20 14:40:25 +00:00
rtptimerqueue.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtptimerqueue.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
rtptwcc.c rtptwcc: don't map the buffer twice 2022-04-26 10:27:25 +00:00
rtptwcc.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00