From 93e49aea1b5563c90f1c5152ab9cb65f19329891 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 Oct 2011 09:49:50 -0400 Subject: [PATCH] Don't use deprecated GThread API in gio tests --- gio/tests/async-close-output-stream.c | 1 - gio/tests/contexts.c | 3 +-- gio/tests/echo-server.c | 1 - gio/tests/gdbus-connection-loss.c | 1 - gio/tests/gdbus-export.c | 9 +++++---- gio/tests/gdbus-non-socket.c | 1 - gio/tests/gdbus-peer.c | 37 +++++++++++++++++++---------------- gio/tests/gdbus-proxy-threads.c | 5 +++-- gio/tests/gdbus-test-codegen.c | 9 +++++---- gio/tests/gdbus-threading.c | 37 +++++++++++++++++++---------------- gio/tests/httpd.c | 1 - gio/tests/resolver.c | 2 +- gio/tests/send-data.c | 3 +-- gio/tests/socket-client.c | 4 +--- gio/tests/socket-server.c | 4 +--- gio/tests/socket.c | 2 +- gio/tests/tls-interaction.c | 3 +-- gio/tests/unix-streams.c | 5 ++--- gio/tests/win32-streams.c | 5 ++--- 19 files changed, 64 insertions(+), 69 deletions(-) diff --git a/gio/tests/async-close-output-stream.c b/gio/tests/async-close-output-stream.c index c4a6c2e..53018a7 100644 --- a/gio/tests/async-close-output-stream.c +++ b/gio/tests/async-close-output-stream.c @@ -248,7 +248,6 @@ main (int argc, SetupData *data; g_type_init (); - g_thread_init (NULL); g_test_init (&argc, &argv, NULL); diff --git a/gio/tests/contexts.c b/gio/tests/contexts.c index 0e9b1af..4d42dac 100644 --- a/gio/tests/contexts.c +++ b/gio/tests/contexts.c @@ -75,7 +75,7 @@ idle_start_test1_thread (gpointer loop) gboolean io_completed; g_mutex_lock (&test1_mutex); - thread = g_thread_create (test1_thread, NULL, TRUE, NULL); + thread = g_thread_new ("test1", test1_thread, NULL, TRUE, NULL); g_get_current_time (&time); time.tv_sec += 2; @@ -179,7 +179,6 @@ main (int argc, char **argv) { GError *error = NULL; - g_thread_init (NULL); g_type_init (); g_test_init (&argc, &argv, NULL); diff --git a/gio/tests/echo-server.c b/gio/tests/echo-server.c index 7e05510..c0a1997 100644 --- a/gio/tests/echo-server.c +++ b/gio/tests/echo-server.c @@ -43,7 +43,6 @@ main (int argc, char *argv[]) GError *error = NULL; g_type_init (); - g_thread_init (NULL); context = g_option_context_new (" - Test GSocket server stuff"); g_option_context_add_main_entries (context, cmd_entries, NULL); diff --git a/gio/tests/gdbus-connection-loss.c b/gio/tests/gdbus-connection-loss.c index 44e97ae..3fdd367 100644 --- a/gio/tests/gdbus-connection-loss.c +++ b/gio/tests/gdbus-connection-loss.c @@ -114,7 +114,6 @@ main (int argc, gint ret; g_type_init (); - g_thread_init (NULL); g_test_init (&argc, &argv, NULL); /* all the tests rely on a shared main loop */ diff --git a/gio/tests/gdbus-export.c b/gio/tests/gdbus-export.c index 4d446f9..a302495 100644 --- a/gio/tests/gdbus-export.c +++ b/gio/tests/gdbus-export.c @@ -940,10 +940,11 @@ test_dispatch (const gchar *object_path) /* run this in a thread to avoid deadlocks */ error = NULL; - thread = g_thread_create (test_dispatch_thread_func, - (gpointer) object_path, - TRUE, - &error); + thread = g_thread_new ("test_dispatch", + test_dispatch_thread_func, + (gpointer) object_path, + TRUE, + &error); g_assert_no_error (error); g_assert (thread != NULL); g_main_loop_run (loop); diff --git a/gio/tests/gdbus-non-socket.c b/gio/tests/gdbus-non-socket.c index 636c853..a45218d 100644 --- a/gio/tests/gdbus-non-socket.c +++ b/gio/tests/gdbus-non-socket.c @@ -341,7 +341,6 @@ main (int argc, gint ret; g_type_init (); - g_thread_init (NULL); g_test_init (&argc, &argv, NULL); /* all the tests rely on a shared main loop */ diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c index 66a3e60..3d98846 100644 --- a/gio/tests/gdbus-peer.c +++ b/gio/tests/gdbus-peer.c @@ -602,10 +602,11 @@ test_peer (void) /* bring up a server - we run the server in a different thread to avoid deadlocks */ error = NULL; - service_thread = g_thread_create (service_thread_func, - &data, - TRUE, - &error); + service_thread = g_thread_new ("test_peer", + service_thread_func, + &data, + TRUE, + &error); while (service_loop == NULL) g_thread_yield (); g_assert (server != NULL); @@ -1051,10 +1052,11 @@ delayed_message_processing (void) data = g_new0 (DmpData, 1); error = NULL; - service_thread = g_thread_create (dmp_thread_func, - data, - TRUE, - &error); + service_thread = g_thread_new ("dmp", + dmp_thread_func, + data, + TRUE, + &error); while (data->server == NULL || !g_dbus_server_is_active (data->server)) g_thread_yield (); @@ -1199,10 +1201,11 @@ test_nonce_tcp (void) error = NULL; server = NULL; service_loop = NULL; - service_thread = g_thread_create (nonce_tcp_service_thread_func, - &data, - TRUE, - &error); + service_thread = g_thread_new ("nonce-tcp-service", + nonce_tcp_service_thread_func, + &data, + TRUE, + &error); while (service_loop == NULL) g_thread_yield (); g_assert (server != NULL); @@ -1508,10 +1511,11 @@ test_tcp_anonymous (void) seen_connection = FALSE; service_loop = NULL; - service_thread = g_thread_create (tcp_anonymous_service_thread_func, - &seen_connection, /* user_data */ - TRUE, /* joinable */ - &error); + service_thread = g_thread_new ("tcp-anon-service", + tcp_anonymous_service_thread_func, + &seen_connection, /* user_data */ + TRUE, /* joinable */ + &error); while (service_loop == NULL) g_thread_yield (); g_assert (server != NULL); @@ -1549,7 +1553,6 @@ main (int argc, gchar *tmpdir = NULL; g_type_init (); - g_thread_init (NULL); g_test_init (&argc, &argv, NULL); g_unsetenv ("DBUS_SESSION_BUS_ADDRESS"); diff --git a/gio/tests/gdbus-proxy-threads.c b/gio/tests/gdbus-proxy-threads.c index d276dc8..f8cd3db 100644 --- a/gio/tests/gdbus-proxy-threads.c +++ b/gio/tests/gdbus-proxy-threads.c @@ -221,8 +221,9 @@ test_proxy (void) for (i = 0; i < n_threads; i++) { - proxy_threads[i] = g_thread_create (run_proxy_thread, connection, TRUE, - &error); + proxy_threads[i] = g_thread_new ("run-proxy", + run_proxy_thread, connection, TRUE, + &error); g_assert_no_error (error); } diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index ebc71ad..3aaefbe 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -565,10 +565,11 @@ on_name_acquired (GDBusConnection *connection, { GMainLoop *loop = user_data; - g_thread_create (check_proxies_in_thread, - loop, - TRUE, - NULL); + g_thread_new ("check-proxies", + check_proxies_in_thread, + loop, + TRUE, + NULL); } static void diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c index 0700ad3..71acda2 100644 --- a/gio/tests/gdbus-threading.c +++ b/gio/tests/gdbus-threading.c @@ -233,10 +233,11 @@ test_delivery_in_thread (void) GThread *thread; error = NULL; - thread = g_thread_create (test_delivery_in_thread_func, - NULL, - TRUE, - &error); + thread = g_thread_new ("deliver", + test_delivery_in_thread_func, + NULL, + TRUE, + &error); g_assert_no_error (error); g_assert (thread != NULL); @@ -394,10 +395,11 @@ test_method_calls_on_proxy (GDBusProxy *proxy) data1.num = 100; data1.async = do_async; data1.done = FALSE; - thread1 = g_thread_create (test_sleep_in_thread_func, - &data1, - TRUE, - &error); + thread1 = g_thread_new ("sleep", + test_sleep_in_thread_func, + &data1, + TRUE, + &error); g_assert_no_error (error); g_assert (thread1 != NULL); @@ -406,10 +408,11 @@ test_method_calls_on_proxy (GDBusProxy *proxy) data2.num = 200; data2.async = do_async; data2.done = FALSE; - thread2 = g_thread_create (test_sleep_in_thread_func, - &data2, - TRUE, - &error); + thread2 = g_thread_new ("sleep2", + test_sleep_in_thread_func, + &data2, + TRUE, + &error); g_assert_no_error (error); g_assert (thread2 != NULL); @@ -418,10 +421,11 @@ test_method_calls_on_proxy (GDBusProxy *proxy) data3.num = 40; data3.async = do_async; data3.done = FALSE; - thread3 = g_thread_create (test_sleep_in_thread_func, - &data3, - TRUE, - &error); + thread3 = g_thread_new ("sleep3", + test_sleep_in_thread_func, + &data3, + TRUE, + &error); g_assert_no_error (error); g_assert (thread3 != NULL); @@ -494,7 +498,6 @@ main (int argc, gint ret; g_type_init (); - g_thread_init (NULL); g_test_init (&argc, &argv, NULL); /* all the tests rely on a shared main loop */ diff --git a/gio/tests/httpd.c b/gio/tests/httpd.c index d8f53e1..a2325d0 100644 --- a/gio/tests/httpd.c +++ b/gio/tests/httpd.c @@ -147,7 +147,6 @@ main (int argc, char *argv[]) GError *error = NULL; g_type_init (); - g_thread_init (NULL); context = g_option_context_new (" - Simple HTTP server"); g_option_context_add_main_entries (context, cmd_entries, NULL); diff --git a/gio/tests/resolver.c b/gio/tests/resolver.c index cec4e26..5d432fc 100644 --- a/gio/tests/resolver.c +++ b/gio/tests/resolver.c @@ -201,7 +201,7 @@ start_sync_lookups (char **argv, int argc) int i; for (i = 0; i < argc; i++) - g_thread_create (lookup_thread, argv[i], FALSE, NULL); + g_thread_new ("lookup", lookup_thread, argv[i], FALSE, NULL); } static void diff --git a/gio/tests/send-data.c b/gio/tests/send-data.c index 189aed2..6ef9382 100644 --- a/gio/tests/send-data.c +++ b/gio/tests/send-data.c @@ -70,7 +70,6 @@ main (int argc, char *argv[]) char buffer[1000]; g_type_init (); - g_thread_init (NULL); context = g_option_context_new (" [:port] - send data to tcp host"); g_option_context_add_main_entries (context, cmd_entries, NULL); @@ -92,7 +91,7 @@ main (int argc, char *argv[]) if (cancel_timeout) { cancellable = g_cancellable_new (); - g_thread_create (cancel_thread, cancellable, FALSE, NULL); + g_thread_new ("cancel", cancel_thread, cancellable, FALSE, NULL); } else { diff --git a/gio/tests/socket-client.c b/gio/tests/socket-client.c index 047f40e..d3b04e2 100644 --- a/gio/tests/socket-client.c +++ b/gio/tests/socket-client.c @@ -261,8 +261,6 @@ main (int argc, GTlsCertificate *certificate = NULL; gint i; - g_thread_init (NULL); - g_type_init (); address = NULL; @@ -291,7 +289,7 @@ main (int argc, if (cancel_timeout) { cancellable = g_cancellable_new (); - g_thread_create (cancel_thread, cancellable, FALSE, NULL); + g_thread_new ("cancel", cancel_thread, cancellable, FALSE, NULL); } else { diff --git a/gio/tests/socket-server.c b/gio/tests/socket-server.c index a44b158..2a442bb 100644 --- a/gio/tests/socket-server.c +++ b/gio/tests/socket-server.c @@ -63,8 +63,6 @@ main (int argc, GInputStream *istream; GOutputStream *ostream; - g_thread_init (NULL); - g_type_init (); context = g_option_context_new (" - Test GSocket server stuff"); @@ -84,7 +82,7 @@ main (int argc, if (cancel_timeout) { cancellable = g_cancellable_new (); - g_thread_create (cancel_thread, cancellable, FALSE, NULL); + g_thread_new ("cancel", cancel_thread, cancellable, FALSE, NULL); } else { diff --git a/gio/tests/socket.c b/gio/tests/socket.c index 3ed030d..cb306d7 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -128,7 +128,7 @@ create_server (GSocketFamily family, g_socket_listen (server, &error); g_assert_no_error (error); - data->thread = g_thread_create (server_thread, data, TRUE, &error); + data->thread = g_thread_new ("server", server_thread, data, TRUE, &error); g_assert_no_error (error); return data; diff --git a/gio/tests/tls-interaction.c b/gio/tests/tls-interaction.c index f619e03..47eaea2 100644 --- a/gio/tests/tls-interaction.c +++ b/gio/tests/tls-interaction.c @@ -437,7 +437,7 @@ setup_with_thread_loop (Test *test, closure.test = test; g_mutex_lock (&closure.loop_mutex); - test->loop_thread = g_thread_create (thread_loop, &closure, TRUE, &error); + test->loop_thread = g_thread_new ("loop", thread_loop, &closure, TRUE, &error); while (!closure.started) g_cond_wait (&closure.loop_started, &closure.loop_mutex); g_mutex_unlock (&closure.loop_mutex); @@ -606,7 +606,6 @@ main (int argc, gint ret; g_type_init (); - g_thread_init (NULL); g_test_init (&argc, &argv, NULL); fixtures = g_ptr_array_new_with_free_func (g_free); diff --git a/gio/tests/unix-streams.c b/gio/tests/unix-streams.c index 2d06b8e..be33037 100644 --- a/gio/tests/unix-streams.c +++ b/gio/tests/unix-streams.c @@ -216,8 +216,8 @@ test_pipe_io (void) reader_cancel = g_cancellable_new (); main_cancel = g_cancellable_new (); - writer = g_thread_create (writer_thread, NULL, TRUE, NULL); - reader = g_thread_create (reader_thread, NULL, TRUE, NULL); + writer = g_thread_new ("writer", writer_thread, NULL, TRUE, NULL); + reader = g_thread_new ("reader", reader_thread, NULL, TRUE, NULL); in = g_unix_input_stream_new (writer_pipe[0], TRUE); out = g_unix_output_stream_new (reader_pipe[1], TRUE); @@ -246,7 +246,6 @@ int main (int argc, char *argv[]) { - g_thread_init (NULL); g_type_init (); g_test_init (&argc, &argv, NULL); diff --git a/gio/tests/win32-streams.c b/gio/tests/win32-streams.c index 4ac04d4..36e98ae 100644 --- a/gio/tests/win32-streams.c +++ b/gio/tests/win32-streams.c @@ -236,8 +236,8 @@ test_pipe_io (void) reader_cancel = g_cancellable_new (); main_cancel = g_cancellable_new (); - writer = g_thread_create (writer_thread, NULL, TRUE, NULL); - reader = g_thread_create (reader_thread, NULL, TRUE, NULL); + writer = g_thread_new ("writer", writer_thread, NULL, TRUE, NULL); + reader = g_thread_new ("reader", reader_thread, NULL, TRUE, NULL); g_assert (DuplicateHandle (GetCurrentProcess (), (HANDLE) (gintptr) _get_osfhandle (writer_pipe[0]), @@ -282,7 +282,6 @@ int main (int argc, char *argv[]) { - g_thread_init (NULL); g_type_init (); g_test_init (&argc, &argv, NULL); -- 2.7.4