mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
tests: bufferpool: add dead lock test for buffer discard
you will see a deadlock after you apply this patch, and run following commandline: GST_STATE_IGNORE_ELEMENTS=1 tests/check/gst_gstbufferpool Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/470>
This commit is contained in:
parent
f41f84538a
commit
8a58d67709
1 changed files with 36 additions and 0 deletions
|
@ -301,6 +301,41 @@ GST_START_TEST (test_flushing_pool_returns_flushing)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static gpointer
|
||||
unref_buf (gpointer p)
|
||||
{
|
||||
GstBuffer *buf = (GstBuffer *) p;
|
||||
/* remove all memory, pool should not reuse this buffer */
|
||||
gst_buffer_remove_all_memory (buf);
|
||||
gst_buffer_unref (buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_no_deadlock_for_buffer_discard)
|
||||
{
|
||||
GstBufferPool *pool;
|
||||
GstBuffer *buf1, *buf2;
|
||||
GThread *thread;
|
||||
|
||||
pool = create_pool (1, 1, 1);
|
||||
fail_unless (pool);
|
||||
gst_buffer_pool_set_active (pool, TRUE);
|
||||
|
||||
fail_unless (gst_buffer_pool_acquire_buffer (pool, &buf1,
|
||||
NULL) == GST_FLOW_OK);
|
||||
thread = g_thread_new (NULL, unref_buf, buf1);
|
||||
fail_unless (thread);
|
||||
/* we will be blocked here until buf1 unrefed */
|
||||
fail_unless (gst_buffer_pool_acquire_buffer (pool, &buf2,
|
||||
NULL) == GST_FLOW_OK);
|
||||
|
||||
gst_buffer_unref (buf2);
|
||||
g_thread_join (thread);
|
||||
gst_object_unref (pool);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_buffer_pool_suite (void)
|
||||
{
|
||||
|
@ -319,6 +354,7 @@ gst_buffer_pool_suite (void)
|
|||
tcase_add_test (tc_chain, test_pool_activation_and_config);
|
||||
tcase_add_test (tc_chain, test_pool_config_validate);
|
||||
tcase_add_test (tc_chain, test_flushing_pool_returns_flushing);
|
||||
tcase_add_test (tc_chain, test_no_deadlock_for_buffer_discard);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue