tests: fix race in streamsynchronizer test
authorTim-Philipp Müller <tim@centricular.com>
Tue, 12 Nov 2013 18:58:43 +0000 (18:58 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Tue, 12 Nov 2013 19:03:19 +0000 (19:03 +0000)
Wait for thread to exit before starting to free the
to_push list, otherwise thread might check the final
to_push->next node only after we've freed it already.

tests/check/elements/streamsynchronizer.c

index c723591..87a14ff 100644 (file)
@@ -162,7 +162,7 @@ my_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
   return TRUE;
 }
 
-static void
+static gpointer
 my_push_thread (MyPushInfo * pushinfo)
 {
   GList *tmp;
@@ -174,6 +174,9 @@ my_push_thread (MyPushInfo * pushinfo)
     else
       gst_pad_push (pushinfo->pad, GST_BUFFER (tmp->data));
   }
+
+  GST_INFO ("leaving thread");
+  return NULL;
 }
 
 GST_START_TEST (test_basic)
@@ -272,6 +275,9 @@ GST_START_TEST (test_basic)
 
   fail_if (expected != NULL);
 
+  /* wait for thread to exit before freeing things */
+  g_thread_join (thread);
+
   /* Cleanup */
   g_list_free (to_push);
   gst_element_release_request_pad (synchr, sinkpad);