gboolean send_msg(gchar *m) { GDBusMessage *msg; msg = g_dbus_message_new_signal("/org/filemon/Object", "org.filemon.Type", "FileChange"); if(NULL == msg) { exit(1); } g_dbus_message_set_body(msg, g_variant_new("(s)",m)); return g_dbus_connection_send_message(conn, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); }
static void test_once (Fixture *f, gconstpointer context) { GDBusMessage *message; gboolean pipe_res; pipe_res = g_unix_open_pipe (f->server_to_client, FD_CLOEXEC, &f->error); g_assert (pipe_res); pipe_res = g_unix_open_pipe (f->client_to_server, FD_CLOEXEC, &f->error); g_assert (pipe_res); f->server_iostream = my_io_stream_new_for_fds (f->client_to_server[0], f->server_to_client[1]); f->iostream = my_io_stream_new_for_fds (f->server_to_client[0], f->client_to_server[1]); g_dbus_connection_new (f->server_iostream, f->guid, (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER | G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS), NULL /* auth observer */, NULL /* cancellable */, on_new_conn, &f->server_conn); g_dbus_connection_new (f->iostream, NULL, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, NULL /* auth observer */, NULL /* cancellable */, on_new_conn, &f->connection); while (f->server_conn == NULL || f->connection == NULL) g_main_context_iteration (NULL, TRUE); /* * queue a message - it'll sometimes be sent while the close is pending, * triggering the bug */ message = g_dbus_message_new_signal ("/", "com.example.Foo", "Bar"); g_dbus_connection_send_message (f->connection, message, 0, NULL, &f->error); g_assert_no_error (f->error); g_object_unref (message); /* close the connection (deliberately or via last-unref) */ if (g_strcmp0 (context, "unref") == 0) { g_clear_object (&f->connection); } else { g_dbus_connection_close_sync (f->connection, NULL, &f->error); g_assert_no_error (f->error); } /* either way, wait for the connection to close */ while (!g_dbus_connection_is_closed (f->server_conn)) g_main_context_iteration (NULL, TRUE); /* clean up before the next run */ g_clear_object (&f->iostream); g_clear_object (&f->server_iostream); g_clear_object (&f->connection); g_clear_object (&f->server_conn); g_clear_error (&f->error); }