[gtk] Try harder to make ci not timeout
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Try harder to make ci not timeout
- Date: Tue, 14 Jan 2020 23:33:11 +0000 (UTC)
commit b020a3fcf9f425ff1cc5b6394a5cd7fe78ddbc8a
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 14 17:38:20 2020 -0500
Try harder to make ci not timeout
Make getting the file transfer portal proxy more
async, and avoid leaking a bus connection. This
causes GTestDBus to hang at the end of the test
run.
gdk/filetransferportal.c | 81 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 59 insertions(+), 22 deletions(-)
---
diff --git a/gdk/filetransferportal.c b/gdk/filetransferportal.c
index 6f31c917ff..7f0a35c303 100644
--- a/gdk/filetransferportal.c
+++ b/gdk/filetransferportal.c
@@ -59,7 +59,39 @@ got_proxy (GObject *source,
g_error_free (error);
}
+ if (timeout_id)
+ {
+ g_source_remove (timeout_id);
+ timeout_id = 0;
+ }
+
done = TRUE;
+ g_main_context_wakeup (NULL);
+}
+
+static void
+got_bus (GObject *source,
+ GAsyncResult *result,
+ gpointer data)
+{
+ GDBusConnection **bus = data;
+ GError *error = NULL;
+
+ *bus = g_bus_get_finish (result, &error);
+ if (!*bus)
+ {
+ g_message ("failed to get session bus connection: %s", error->message);
+ g_error_free (error);
+ }
+
+ if (timeout_id)
+ {
+ g_source_remove (timeout_id);
+ timeout_id = 0;
+ }
+
+ done = TRUE;
+ g_main_context_wakeup (NULL);
}
static gboolean
@@ -70,8 +102,8 @@ give_up_on_proxy (gpointer data)
g_cancellable_cancel (cancellable);
timeout_id = 0;
- done = TRUE;
+ done = TRUE;
g_main_context_wakeup (NULL);
return G_SOURCE_REMOVE;
@@ -82,35 +114,40 @@ ensure_file_transfer_portal (void)
{
if (file_transfer_proxy == NULL)
{
- GError *error = NULL;
GCancellable *cancellable;
+ GDBusConnection *bus = NULL;
cancellable = g_cancellable_new ();
-
- g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
- | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
- | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- NULL,
- "org.freedesktop.portal.Documents",
- "/org/freedesktop/portal/documents",
- "org.freedesktop.portal.FileTransfer",
- cancellable,
- got_proxy,
- NULL);
-
- timeout_id = g_timeout_add_full (1000, 0, give_up_on_proxy, cancellable, g_object_unref);
+
+ done = FALSE;
+ timeout_id = g_timeout_add_full (500, 0, give_up_on_proxy, cancellable, g_object_unref);
+ g_bus_get (G_BUS_TYPE_SESSION,
+ cancellable,
+ got_bus,
+ &bus);
while (!done)
g_main_context_iteration (NULL, TRUE);
- if (timeout_id)
- g_source_remove (timeout_id);
-
- if (error)
+ if (bus)
{
- g_debug ("Failed to get proxy: %s", error->message);
- g_error_free (error);
+ timeout_id = g_timeout_add_full (500, 0, give_up_on_proxy, cancellable, g_object_unref);
+ g_dbus_proxy_new (bus,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
+ | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
+ | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ NULL,
+ "org.freedesktop.portal.Documents",
+ "/org/freedesktop/portal/documents",
+ "org.freedesktop.portal.FileTransfer",
+ cancellable,
+ got_proxy,
+ NULL);
+
+ while (!done)
+ g_main_context_iteration (NULL, TRUE);
+
+ g_clear_object (&bus);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]