mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
dtls: Catch bus errors and fail instead of hanging.
If the DTLS elements fail, they post a bus error and don't signal any key negotiation. Catch the bus error and fail the test early instead of letting it hang and time out. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1741>
This commit is contained in:
parent
dbeb576531
commit
c1be9c53e1
1 changed files with 32 additions and 1 deletions
|
@ -51,6 +51,20 @@ GST_END_TEST;
|
||||||
static GMutex key_lock;
|
static GMutex key_lock;
|
||||||
static GCond key_cond;
|
static GCond key_cond;
|
||||||
static int key_count;
|
static int key_count;
|
||||||
|
static gboolean errored;
|
||||||
|
|
||||||
|
static GstBusSyncReply
|
||||||
|
bus_msg_handler (GstBus * bus, GstMessage * message, gpointer user_data)
|
||||||
|
{
|
||||||
|
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
|
||||||
|
g_mutex_lock (&key_lock);
|
||||||
|
errored = TRUE;
|
||||||
|
g_cond_broadcast (&key_cond);
|
||||||
|
g_mutex_unlock (&key_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GST_BUS_PASS;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_on_key_received (GstElement * element, gpointer user_data)
|
_on_key_received (GstElement * element, gpointer user_data)
|
||||||
|
@ -65,8 +79,16 @@ static void
|
||||||
_wait_for_key_count_to_reach (int n)
|
_wait_for_key_count_to_reach (int n)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&key_lock);
|
g_mutex_lock (&key_lock);
|
||||||
while (key_count < n)
|
while (key_count < n) {
|
||||||
g_cond_wait (&key_cond, &key_lock);
|
g_cond_wait (&key_cond, &key_lock);
|
||||||
|
|
||||||
|
/* Check if any errors were posted */
|
||||||
|
if (errored) {
|
||||||
|
g_mutex_unlock (&key_lock);
|
||||||
|
fail ("DTLS element posted an error");
|
||||||
|
g_mutex_lock (&key_lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
g_mutex_unlock (&key_lock);
|
g_mutex_unlock (&key_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +102,7 @@ GST_START_TEST (test_data_transfer)
|
||||||
GstElement *s_enc, *s_dec, *c_enc, *c_dec, *s_bin, *c_bin;
|
GstElement *s_enc, *s_dec, *c_enc, *c_dec, *s_bin, *c_bin;
|
||||||
GstPad *target, *ghost;
|
GstPad *target, *ghost;
|
||||||
GstBuffer *buffer, *buf2;
|
GstBuffer *buffer, *buf2;
|
||||||
|
GstBus *bus;
|
||||||
|
|
||||||
/* setup a server and client for dtls negotiation */
|
/* setup a server and client for dtls negotiation */
|
||||||
s_bin = gst_bin_new (NULL);
|
s_bin = gst_bin_new (NULL);
|
||||||
|
@ -149,6 +172,14 @@ GST_START_TEST (test_data_transfer)
|
||||||
gst_harness_set_src_caps_str (server, "application/data");
|
gst_harness_set_src_caps_str (server, "application/data");
|
||||||
gst_harness_set_src_caps_str (client, "application/data");
|
gst_harness_set_src_caps_str (client, "application/data");
|
||||||
|
|
||||||
|
bus = gst_bus_new ();
|
||||||
|
gst_bus_set_sync_handler (bus, bus_msg_handler, NULL, NULL);
|
||||||
|
|
||||||
|
gst_element_set_bus (s_bin, bus);
|
||||||
|
gst_element_set_bus (c_bin, bus);
|
||||||
|
|
||||||
|
gst_object_unref (bus);
|
||||||
|
|
||||||
_wait_for_key_count_to_reach (4);
|
_wait_for_key_count_to_reach (4);
|
||||||
|
|
||||||
buffer = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, data,
|
buffer = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, data,
|
||||||
|
|
Loading…
Reference in a new issue