7 #include "test-thread.h"
9 DBusConnection *connection;
12 thread_func (gpointer data)
14 gint32 threadnr = GPOINTER_TO_INT (data);
21 message = dbus_message_new (NULL, "org.freedesktop.ThreadTest");
23 if (!dbus_message_append_int32 (message, threadnr))
25 g_print ("thread %d: append threadnr failed\n", threadnr);
28 if (!dbus_message_append_uint32 (message, counter))
30 g_print ("thread %d: append counter (%d) failed\n", threadnr, counter);
33 str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter);
34 if (!dbus_message_append_string (message, str))
36 g_print ("thread %d: append string (%s) failed\n", threadnr, str);
40 if (!dbus_connection_send (connection,
44 g_print ("thread %d: send message failed\n", threadnr);
47 dbus_message_unref (message);
56 main (int argc, char *argv[])
59 DBusResultCode result;
67 g_error("Need an address as argv[1]\n");
71 connection = dbus_connection_open (argv[1], &result);
72 if (connection == NULL)
74 g_printerr ("could not open connection\n");
78 dbus_connection_setup_with_g_main (connection);
80 for (i = 0; i < N_TEST_THREADS; i++)
82 g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL);
85 loop = g_main_loop_new (NULL, FALSE);