From fa1c711a2f815a8c86c4ae3c4bf513bf80b0e1bf Mon Sep 17 00:00:00 2001 From: Mikhail Fludkov Date: Sun, 15 Nov 2015 14:54:28 +0100 Subject: rtpsession: Add test for locking of the stats signal Keeping the lock while emitting the stats signal introduces potential deadlock in those situations when the signal callback wants the access to rtpsession's properties which also requre the lock. https://bugzilla.gnome.org/show_bug.cgi?id=762216 --- tests/check/elements/rtpsession.c | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/check/elements/rtpsession.c b/tests/check/elements/rtpsession.c index 296b958a9..2f1955437 100644 --- a/tests/check/elements/rtpsession.c +++ b/tests/check/elements/rtpsession.c @@ -658,6 +658,50 @@ GST_START_TEST (test_receive_rtcp_app_packet) GST_END_TEST; +static void +stats_test_cb (GObject * object, GParamSpec * spec, gpointer data) +{ + guint num_sources = 0; + gboolean *cb_called = data; + g_assert (*cb_called == FALSE); + *cb_called = TRUE; + + /* We should be able to get a rtpsession property + without introducing the deadlock */ + g_object_get (object, "num-sources", &num_sources, NULL); +} + +GST_START_TEST (test_dont_lock_on_stats) +{ + GstHarness * h_rtcp; + GstHarness * h_send; + GstClock * clock = gst_test_clock_new (); + GstTestClock * testclock = GST_TEST_CLOCK (clock); + gboolean cb_called = FALSE; + + /* use testclock as the systemclock to capture the rtcp thread waits */ + gst_system_clock_set_default (GST_CLOCK (testclock)); + + h_rtcp = gst_harness_new_with_padnames ( + "rtpsession", "recv_rtcp_sink", "send_rtcp_src"); + h_send = gst_harness_new_with_element ( + h_rtcp->element, "send_rtp_sink", "send_rtp_src"); + + /* connect to the stats-reporting */ + g_signal_connect (h_rtcp->element, "notify::stats", + G_CALLBACK (stats_test_cb), &cb_called); + + /* "crank" and check the stats */ + g_assert (gst_test_clock_crank (testclock)); + gst_buffer_unref (gst_harness_pull (h_rtcp)); + fail_unless (cb_called); + + gst_harness_teardown (h_send); + gst_harness_teardown (h_rtcp); + gst_object_unref (clock); +} +GST_END_TEST; + static Suite * rtpsession_suite (void) { @@ -670,6 +714,7 @@ rtpsession_suite (void) tcase_add_test (tc_chain, test_internal_sources_timeout); tcase_add_test (tc_chain, test_receive_rtcp_app_packet); + tcase_add_test (tc_chain, test_dont_lock_on_stats); return s; } -- cgit v1.2.3