gdbus-connection: Work around race in connection tests
[platform/upstream/glib.git] / gio / tests / socket-server.c
index d48a5a4..decf3ec 100644 (file)
@@ -63,10 +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");
   g_option_context_add_main_entries (context, cmd_entries, NULL);
   if (!g_option_context_parse (context, &argc, &argv, &error))
@@ -83,8 +79,10 @@ main (int argc,
 
   if (cancel_timeout)
     {
+      GThread *thread;
       cancellable = g_cancellable_new ();
-      g_thread_create (cancel_thread, cancellable, FALSE, NULL);
+      thread = g_thread_new ("cancel", cancel_thread, cancellable);
+      g_thread_unref (thread);
     }
   else
     {
@@ -211,7 +209,7 @@ main (int argc,
 
   if (tlscert)
     {
-      GTlsServerConnection *tls_conn;
+      GIOStream *tls_conn;
 
       tls_conn = g_tls_server_connection_new (connection, tlscert, &error);
       if (!tls_conn)
@@ -230,7 +228,7 @@ main (int argc,
        }
 
       g_object_unref (connection);
-      connection = G_IO_STREAM (tls_conn);
+      connection = tls_conn;
     }
 
   if (connection)
@@ -238,6 +236,12 @@ main (int argc,
       istream = g_io_stream_get_input_stream (connection);
       ostream = g_io_stream_get_output_stream (connection);
     }
+  else
+    {
+      g_assert (use_udp);
+      istream = NULL;
+      ostream = NULL;
+    }
 
   while (TRUE)
     {