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_message (connection,
44 g_print ("thread %d: send message failerd\n", threadnr);
46 dbus_message_unref (message);
55 main (int argc, char *argv[])
58 DBusResultCode result;
66 g_error("Need an address as argv[1]\n");
70 connection = dbus_connection_open (argv[1], &result);
71 if (connection == NULL)
73 g_printerr ("could not open connection\n");
77 dbus_connection_setup_with_g_main (connection);
79 for (i = 0; i < N_TEST_THREADS; i++)
81 g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL);
84 loop = g_main_loop_new (NULL, FALSE);