#include #include #include #include #include #include DBusConnection *connection; void *fun(void*a) { DBusError error; dbus_error_init (&error); int cnt = 1; while (1) { DBusMessageIter iter; DBusMessage* message = dbus_message_new_method_call (NULL, "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames"); dbus_message_set_auto_start (message, TRUE); dbus_message_set_destination (message, "org.freedesktop.DBus"); dbus_message_iter_init_append (message, &iter); DBusMessage *reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error); usleep(rand()%100000); dbus_message_unref(reply); usleep(rand()%100000); dbus_message_unref(message); usleep(rand()%100000); if (cnt++%30 == 0) fprintf(stderr, "."); } return 0; } int main(int argc, char **argv) { DBusError error; srand(time(0)); dbus_error_init (&error); connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); int i; for (i = 0; i < 100; i++) { pthread_t thr; pthread_create(&thr, NULL, fun, NULL); } for (;;) sleep(1000); dbus_connection_unref(connection); return 0; }