Blame SOURCES/0001-libgdm-drop-support-for-serializing-multiple-opens.patch

b61949
From 30d02d642714b2417be28d430f7d4c602d38a03b Mon Sep 17 00:00:00 2001
b61949
From: Ray Strode <rstrode@redhat.com>
b61949
Date: Mon, 14 May 2018 14:48:31 -0400
b61949
Subject: [PATCH 01/15] libgdm: drop support for serializing multiple opens
b61949
b61949
Right now libgdm tries to handle multiple simultaneous
b61949
open calls at the same time by serializing the requests
b61949
and giving them all the same connection.  It's broken,
b61949
though.
b61949
b61949
  - The pending_opens list is never populated, so we
b61949
    end up just doing multiple simultaneous open
b61949
    operations at a time anyway.
b61949
  - The finish code ends up calling
b61949
    g_task_return_error (task, NULL) instead of
b61949
    g_task_return_pointer in the non-error case.
b61949
b61949
Since the feature doesn't work, drop it for now.
b61949
b61949
https://bugzilla.gnome.org/show_bug.cgi?id=795940
b61949
---
b61949
 libgdm/gdm-client.c | 111 ++++++++++++++++----------------------------
b61949
 1 file changed, 40 insertions(+), 71 deletions(-)
b61949
b61949
diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c
b61949
index 58ede0aab..06dfe725e 100644
b61949
--- a/libgdm/gdm-client.c
b61949
+++ b/libgdm/gdm-client.c
b61949
@@ -24,61 +24,60 @@
b61949
 #include <stdlib.h>
b61949
 #include <stdio.h>
b61949
 #include <unistd.h>
b61949
 #include <string.h>
b61949
 
b61949
 #include <glib.h>
b61949
 #include <glib/gi18n.h>
b61949
 #include <glib-object.h>
b61949
 
b61949
 #include "gdm-client.h"
b61949
 #include "gdm-client-glue.h"
b61949
 #include "gdm-manager-glue.h"
b61949
 
b61949
 #define GDM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_CLIENT, GdmClientPrivate))
b61949
 
b61949
 #define SESSION_DBUS_PATH      "/org/gnome/DisplayManager/Session"
b61949
 
b61949
 struct GdmClientPrivate
b61949
 {
b61949
         GdmManager         *manager;
b61949
 
b61949
         GdmUserVerifier    *user_verifier;
b61949
         GHashTable         *user_verifier_extensions;
b61949
 
b61949
         GdmGreeter         *greeter;
b61949
         GdmRemoteGreeter   *remote_greeter;
b61949
         GdmChooser         *chooser;
b61949
         GDBusConnection    *connection;
b61949
         char               *address;
b61949
 
b61949
-        GList              *pending_opens;
b61949
         char              **enabled_extensions;
b61949
 };
b61949
 
b61949
 static void     gdm_client_class_init  (GdmClientClass *klass);
b61949
 static void     gdm_client_init        (GdmClient      *client);
b61949
 static void     gdm_client_finalize    (GObject        *object);
b61949
 
b61949
 G_DEFINE_TYPE (GdmClient, gdm_client, G_TYPE_OBJECT);
b61949
 
b61949
 static gpointer client_object = NULL;
b61949
 
b61949
 GQuark
b61949
 gdm_client_error_quark (void)
b61949
 {
b61949
         static GQuark error_quark = 0;
b61949
 
b61949
         if (error_quark == 0)
b61949
                 error_quark = g_quark_from_static_string ("gdm-client");
b61949
 
b61949
         return error_quark;
b61949
 }
b61949
 
b61949
 static void
b61949
 on_got_manager (GdmManager          *manager,
b61949
                 GAsyncResult        *result,
b61949
                 GTask               *task)
b61949
 {
b61949
         GdmClient *client;
b61949
         GdmManager       *new_manager;
b61949
         GError           *error;
b61949
@@ -396,107 +395,104 @@ on_got_manager_for_reauthentication (GdmClient           *client,
b61949
         GError       *error;
b61949
 
b61949
         error = NULL;
b61949
         manager = g_task_propagate_pointer (G_TASK (result), &error);
b61949
         if (manager == NULL) {
b61949
                 g_task_return_error (task, error);
b61949
                 g_object_unref (task);
b61949
                 return;
b61949
         }
b61949
 
b61949
         cancellable = g_task_get_cancellable (task);
b61949
         username = g_object_get_data (G_OBJECT (task), "username");
b61949
         gdm_manager_call_open_reauthentication_channel (client->priv->manager,
b61949
                                                         username,
b61949
                                                         cancellable,
b61949
                                                         (GAsyncReadyCallback)
b61949
                                                         on_reauthentication_channel_opened,
b61949
                                                         task);
b61949
 
b61949
 }
b61949
 
b61949
 static gboolean
b61949
 gdm_client_open_connection_sync (GdmClient      *client,
b61949
                                  GCancellable   *cancellable,
b61949
                                  GError        **error)
b61949
 {
b61949
         gboolean ret;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
-        if (client->priv->manager == NULL) {
b61949
-                client->priv->manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
b61949
-                                                                            G_DBUS_PROXY_FLAGS_NONE,
b61949
-                                                                            "org.gnome.DisplayManager",
b61949
-                                                                            "/org/gnome/DisplayManager/Manager",
b61949
-                                                                            cancellable,
b61949
-                                                                            error);
b61949
-
b61949
-                if (client->priv->manager == NULL) {
b61949
-                        goto out;
b61949
-                }
b61949
-        } else {
b61949
-                client->priv->manager = g_object_ref (client->priv->manager);
b61949
+        if (client->priv->connection != NULL) {
b61949
+                g_object_ref (client->priv->connection);
b61949
+                return TRUE;
b61949
         }
b61949
 
b61949
-        if (client->priv->connection == NULL) {
b61949
-                ret = gdm_manager_call_open_session_sync (client->priv->manager,
b61949
-                                                          &client->priv->address,
b61949
-                                                          cancellable,
b61949
-                                                          error);
b61949
+        client->priv->manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
b61949
+                                                                    G_DBUS_PROXY_FLAGS_NONE,
b61949
+                                                                    "org.gnome.DisplayManager",
b61949
+                                                                    "/org/gnome/DisplayManager/Manager",
b61949
+                                                                    cancellable,
b61949
+                                                                    error);
b61949
 
b61949
-                if (!ret) {
b61949
-                        g_clear_object (&client->priv->manager);
b61949
-                        goto out;
b61949
-                }
b61949
+        if (client->priv->manager == NULL) {
b61949
+                goto out;
b61949
+        }
b61949
+
b61949
+        ret = gdm_manager_call_open_session_sync (client->priv->manager,
b61949
+                                                  &client->priv->address,
b61949
+                                                  cancellable,
b61949
+                                                  error);
b61949
 
b61949
-                g_debug ("GdmClient: connecting to address: %s", client->priv->address);
b61949
+        if (!ret) {
b61949
+                g_clear_object (&client->priv->manager);
b61949
+                goto out;
b61949
+        }
b61949
 
b61949
-                client->priv->connection = g_dbus_connection_new_for_address_sync (client->priv->address,
b61949
-                                                                                   G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
b61949
-                                                                                   NULL,
b61949
-                                                                                   cancellable,
b61949
-                                                                                   error);
b61949
+        g_debug ("GdmClient: connecting to address: %s", client->priv->address);
b61949
 
b61949
-                if (client->priv->connection == NULL) {
b61949
-                        g_clear_object (&client->priv->manager);
b61949
-                        g_clear_pointer (&client->priv->address, g_free);
b61949
-                        goto out;
b61949
-                }
b61949
+        client->priv->connection = g_dbus_connection_new_for_address_sync (client->priv->address,
b61949
+                                                                           G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
b61949
+                                                                           NULL,
b61949
+                                                                           cancellable,
b61949
+                                                                           error);
b61949
 
b61949
-                g_object_add_weak_pointer (G_OBJECT (client->priv->connection),
b61949
-                                           (gpointer *)
b61949
-                                           &client->priv->connection);
b61949
-        } else {
b61949
-                client->priv->connection = g_object_ref (client->priv->connection);
b61949
+        if (client->priv->connection == NULL) {
b61949
+                g_clear_object (&client->priv->manager);
b61949
+                g_clear_pointer (&client->priv->address, g_free);
b61949
+                goto out;
b61949
         }
b61949
 
b61949
+        g_object_add_weak_pointer (G_OBJECT (client->priv->connection),
b61949
+                                   (gpointer *)
b61949
+                                   &client->priv->connection);
b61949
+
b61949
  out:
b61949
         return client->priv->connection != NULL;
b61949
 }
b61949
 
b61949
 static void
b61949
 on_connected (GObject            *source_object,
b61949
               GAsyncResult       *result,
b61949
               GTask              *task)
b61949
 {
b61949
         GDBusConnection *connection;
b61949
         GError *error;
b61949
 
b61949
         error = NULL;
b61949
         connection = g_dbus_connection_new_for_address_finish (result, &error);
b61949
         if (!connection) {
b61949
                 g_task_return_error (task, error);
b61949
                 g_object_unref (task);
b61949
                 return;
b61949
         }
b61949
 
b61949
         g_task_return_pointer (task,
b61949
                                g_object_ref (connection),
b61949
                                (GDestroyNotify) g_object_unref);
b61949
         g_object_unref (task);
b61949
         g_object_unref (connection);
b61949
 }
b61949
 
b61949
 static void
b61949
 on_session_opened (GdmManager         *manager,
b61949
                    GAsyncResult       *result,
b61949
@@ -528,140 +524,113 @@ on_session_opened (GdmManager         *manager,
b61949
                                            on_connected,
b61949
                                            task);
b61949
         g_object_unref (client);
b61949
 }
b61949
 
b61949
 static void
b61949
 on_got_manager_for_opening_connection (GdmClient           *client,
b61949
                                        GAsyncResult        *result,
b61949
                                        GTask               *task)
b61949
 {
b61949
         GCancellable *cancellable;
b61949
         GdmManager   *manager;
b61949
         GError       *error;
b61949
 
b61949
         error = NULL;
b61949
         manager = g_task_propagate_pointer (G_TASK (result), &error);
b61949
         if (manager == NULL) {
b61949
                 g_task_return_error (task, error);
b61949
                 g_object_unref (task);
b61949
                 return;
b61949
         }
b61949
 
b61949
         cancellable = g_task_get_cancellable (task);
b61949
         gdm_manager_call_open_session (client->priv->manager,
b61949
                                        cancellable,
b61949
                                        (GAsyncReadyCallback)
b61949
                                        on_session_opened,
b61949
                                        task);
b61949
 }
b61949
 
b61949
-static void
b61949
-finish_pending_opens (GdmClient *client,
b61949
-                      GError    *error)
b61949
-{
b61949
-    GList *node;
b61949
-
b61949
-    for (node = client->priv->pending_opens;
b61949
-         node != NULL;
b61949
-         node = node->next) {
b61949
-
b61949
-        GTask *task = node->data;
b61949
-
b61949
-        g_task_return_error (task, error);
b61949
-        g_object_unref (task);
b61949
-    }
b61949
-    g_clear_pointer (&client->priv->pending_opens,
b61949
-                     (GDestroyNotify) g_list_free);
b61949
-}
b61949
-
b61949
 static gboolean
b61949
 gdm_client_open_connection_finish (GdmClient      *client,
b61949
                                    GAsyncResult   *result,
b61949
                                    GError        **error)
b61949
 {
b61949
         g_autoptr(GDBusConnection) connection = NULL;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
         connection = g_task_propagate_pointer (G_TASK (result), error);
b61949
         if (connection == NULL) {
b61949
-                finish_pending_opens (client, *error);
b61949
                 return FALSE;
b61949
         }
b61949
 
b61949
         if (client->priv->connection == NULL) {
b61949
                 client->priv->connection = g_steal_pointer (&connection);
b61949
                 g_object_add_weak_pointer (G_OBJECT (client->priv->connection),
b61949
                                            (gpointer *) &client->priv->connection);
b61949
         } else if (client->priv->connection == connection) {
b61949
                 connection = NULL;
b61949
         }
b61949
 
b61949
-        finish_pending_opens (client, NULL);
b61949
         return TRUE;
b61949
 }
b61949
 
b61949
 static void
b61949
 gdm_client_open_connection (GdmClient           *client,
b61949
                             GCancellable        *cancellable,
b61949
                             GAsyncReadyCallback  callback,
b61949
                             gpointer             user_data)
b61949
 {
b61949
         GTask *task;
b61949
 
b61949
         g_return_if_fail (GDM_IS_CLIENT (client));
b61949
 
b61949
         task = g_task_new (G_OBJECT (client),
b61949
                            cancellable,
b61949
                            callback,
b61949
                            user_data);
b61949
 
b61949
         if (client->priv->connection != NULL) {
b61949
             g_task_return_pointer (task,
b61949
                                    g_object_ref (client->priv->connection),
b61949
                                    (GDestroyNotify) g_object_unref);
b61949
             g_object_unref (task);
b61949
             return;
b61949
         }
b61949
 
b61949
-        if (client->priv->pending_opens == NULL) {
b61949
-            get_manager (client,
b61949
-                         cancellable,
b61949
-                         (GAsyncReadyCallback)
b61949
-                         on_got_manager_for_opening_connection,
b61949
-                         task);
b61949
-        } else {
b61949
-                client->priv->pending_opens = g_list_prepend (client->priv->pending_opens,
b61949
-                                                              task);
b61949
-        }
b61949
-
b61949
+        get_manager (client,
b61949
+                     cancellable,
b61949
+                     (GAsyncReadyCallback)
b61949
+                     on_got_manager_for_opening_connection,
b61949
+                     task);
b61949
 }
b61949
 
b61949
 /**
b61949
  * gdm_client_open_reauthentication_channel_sync:
b61949
  * @client: a #GdmClient
b61949
  * @username: user to reauthenticate
b61949
  * @cancellable: a #GCancellable
b61949
  * @error: a #GError
b61949
  *
b61949
  * Gets a #GdmUserVerifier object that can be used to
b61949
  * reauthenticate an already logged in user. Free with
b61949
  * g_object_unref to close reauthentication channel.
b61949
  *
b61949
  * Returns: (transfer full): #GdmUserVerifier or %NULL if @username is not
b61949
  * already logged in.
b61949
  */
b61949
 GdmUserVerifier *
b61949
 gdm_client_open_reauthentication_channel_sync (GdmClient     *client,
b61949
                                                const char    *username,
b61949
                                                GCancellable  *cancellable,
b61949
                                                GError       **error)
b61949
 {
b61949
         GDBusConnection *connection;
b61949
         GdmUserVerifier *user_verifier = NULL;
b61949
         gboolean         ret;
b61949
         char            *address;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
         if (client->priv->manager == NULL) {
b61949
-- 
52125b
2.25.1
b61949