Blame SOURCES/0001-tests-Avoid-race-condition-in-threaded-tests.patch

b59e85
From 08f1fc35e3c77aecedacf08aa510e82c91ac7f2a Mon Sep 17 00:00:00 2001
b59e85
From: Christophe Fergeau <cfergeau@redhat.com>
b59e85
Date: Tue, 17 Mar 2015 15:53:36 +0100
b59e85
Subject: [PATCH] tests: Avoid race condition in threaded tests
b59e85
b59e85
Calling soup_server_run in a new thread, and calling
b59e85
soup_server_get_port() on the same SoupServer instance
b59e85
right after creating the thread.
b59e85
With recent libsoup, this sometimes causes a crash when the 2 threads
b59e85
try to call soup_server_ensure_listening() at the same time.
b59e85
Moving the call to soup_server_get_port() before the thread creation
b59e85
avoids this race condition.
b59e85
---
b59e85
 tests/custom-serialize.c | 4 ++--
b59e85
 tests/threaded.c         | 4 ++--
b59e85
 2 files changed, 4 insertions(+), 4 deletions(-)
b59e85
b59e85
diff --git a/tests/custom-serialize.c b/tests/custom-serialize.c
b59e85
index f683941d297a..c4ca5413cad1 100644
b59e85
--- a/tests/custom-serialize.c
b59e85
+++ b/tests/custom-serialize.c
b59e85
@@ -123,10 +123,10 @@ main (int argc, char **argv)
b59e85
 
b59e85
   server = soup_server_new (NULL);
b59e85
   soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
b59e85
-  g_thread_create ((GThreadFunc)soup_server_run, server, FALSE, NULL);
b59e85
-
b59e85
   url = g_strdup_printf ("http://127.0.0.1:%d/", soup_server_get_port (server));
b59e85
 
b59e85
+  g_thread_create ((GThreadFunc)soup_server_run, server, FALSE, NULL);
b59e85
+
b59e85
   proxy = rest_proxy_new (url, FALSE);
b59e85
   call = g_object_new (REST_TYPE_CUSTOM_PROXY_CALL, "proxy", proxy, NULL);
b59e85
 
b59e85
diff --git a/tests/threaded.c b/tests/threaded.c
b59e85
index ecb074fd76c7..abb11e7a42d3 100644
b59e85
--- a/tests/threaded.c
b59e85
+++ b/tests/threaded.c
b59e85
@@ -90,10 +90,10 @@ main (int argc, char **argv)
b59e85
 
b59e85
   server = soup_server_new (NULL);
b59e85
   soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
b59e85
-  g_thread_create ((GThreadFunc)soup_server_run, server, FALSE, NULL);
b59e85
-
b59e85
   url = g_strdup_printf ("http://127.0.0.1:%d/", soup_server_get_port (server));
b59e85
 
b59e85
+  g_thread_create ((GThreadFunc)soup_server_run, server, FALSE, NULL);
b59e85
+
b59e85
   for (i = 0; i < G_N_ELEMENTS (threads); i++) {
b59e85
     threads[i] = g_thread_create (func, url, TRUE, NULL);
b59e85
     if (verbose)
b59e85
-- 
b59e85
2.5.0
b59e85