summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Fludkov <misha@pexip.com>2015-11-15 14:54:28 +0100
committerSebastian Dröge <sebastian@centricular.com>2016-05-20 09:26:20 +0300
commitfa1c711a2f815a8c86c4ae3c4bf513bf80b0e1bf (patch)
tree704a08f9a0c686f8e83349644086975db26f6c83
parenteb09829a1c1987373ae433daca6420ea6c0fb908 (diff)
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
-rw-r--r--tests/check/elements/rtpsession.c45
1 files changed, 45 insertions, 0 deletions
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;
}