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
This commit is contained in:
Mikhail Fludkov 2015-11-15 14:54:28 +01:00 committed by Sebastian Dröge
parent eb09829a1c
commit fa1c711a2f

View file

@ -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;
}