summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2018-06-04 22:34:59 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2018-06-04 22:41:23 +0200
commitde270bca5a3037fe43d3661511e0d1f3f449d874 (patch)
treec91bb91297e3a21bdecd335e6455481cb03ae91a
parentc58a4f4f1ee1fcf34fdf1fc8f22def7e5455a182 (diff)
downloadgdm-de270bca5a3037fe43d3661511e0d1f3f449d874.tar.gz
libgdm: don't keep manager proxy around longer than we need it
Right now we keep the manager proxy alive long after we need it. It doesn't get cleared until one of the other proxies go away. That is not only unnecessary but illogical and confusing. This commit changes the manager proxy to be transient—only alive long enough to get what we need from it. https://bugzilla.gnome.org/show_bug.cgi?id=795940
-rw-r--r--libgdm/gdm-client.c127
1 files changed, 30 insertions, 97 deletions
diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c
index 06dfe725..c34121e6 100644
--- a/libgdm/gdm-client.c
+++ b/libgdm/gdm-client.c
@@ -40,8 +40,6 @@
struct GdmClientPrivate
{
- GdmManager *manager;
-
GdmUserVerifier *user_verifier;
GHashTable *user_verifier_extensions;
@@ -74,34 +72,24 @@ gdm_client_error_quark (void)
}
static void
-on_got_manager (GdmManager *manager,
+on_got_manager (GObject *object,
GAsyncResult *result,
GTask *task)
{
GdmClient *client;
- GdmManager *new_manager;
- GError *error;
+ GError *error;
+ g_autoptr(GdmManager) manager = NULL;
client = GDM_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (task)));
error = NULL;
- new_manager = gdm_manager_proxy_new_finish (result, &error);
-
- if (client->priv->manager == NULL) {
- client->priv->manager = new_manager;
-
- } else {
- g_object_ref (client->priv->manager);
- g_object_unref (new_manager);
-
- g_clear_error (&error);
- }
+ manager = gdm_manager_proxy_new_finish (result, &error);
if (error != NULL) {
g_task_return_error (task, error);
} else {
g_task_return_pointer (task,
- g_object_ref (client->priv->manager),
+ g_object_ref (manager),
(GDestroyNotify) g_object_unref);
}
@@ -122,14 +110,6 @@ get_manager (GdmClient *client,
callback,
user_data);
- if (client->priv->manager != NULL) {
- g_task_return_pointer (task,
- g_object_ref (client->priv->manager),
- (GDestroyNotify) g_object_unref);
- g_object_unref (task);
- return;
- }
-
gdm_manager_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
"org.gnome.DisplayManager",
@@ -404,7 +384,7 @@ on_got_manager_for_reauthentication (GdmClient *client,
cancellable = g_task_get_cancellable (task);
username = g_object_get_data (G_OBJECT (task), "username");
- gdm_manager_call_open_reauthentication_channel (client->priv->manager,
+ gdm_manager_call_open_reauthentication_channel (manager,
username,
cancellable,
(GAsyncReadyCallback)
@@ -418,6 +398,7 @@ gdm_client_open_connection_sync (GdmClient *client,
GCancellable *cancellable,
GError **error)
{
+ g_autoptr(GdmManager) manager = NULL;
gboolean ret;
g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
@@ -427,24 +408,23 @@ gdm_client_open_connection_sync (GdmClient *client,
return TRUE;
}
- client->priv->manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.DisplayManager",
- "/org/gnome/DisplayManager/Manager",
- cancellable,
- error);
+ manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.gnome.DisplayManager",
+ "/org/gnome/DisplayManager/Manager",
+ cancellable,
+ error);
- if (client->priv->manager == NULL) {
+ if (manager == NULL) {
goto out;
}
- ret = gdm_manager_call_open_session_sync (client->priv->manager,
+ ret = gdm_manager_call_open_session_sync (manager,
&client->priv->address,
cancellable,
error);
if (!ret) {
- g_clear_object (&client->priv->manager);
goto out;
}
@@ -457,7 +437,6 @@ gdm_client_open_connection_sync (GdmClient *client,
error);
if (client->priv->connection == NULL) {
- g_clear_object (&client->priv->manager);
g_clear_pointer (&client->priv->address, g_free);
goto out;
}
@@ -544,7 +523,7 @@ on_got_manager_for_opening_connection (GdmClient *client,
}
cancellable = g_task_get_cancellable (task);
- gdm_manager_call_open_session (client->priv->manager,
+ gdm_manager_call_open_session (manager,
cancellable,
(GAsyncReadyCallback)
on_session_opened,
@@ -627,28 +606,25 @@ gdm_client_open_reauthentication_channel_sync (GdmClient *client,
GError **error)
{
GDBusConnection *connection;
+ g_autoptr(GdmManager) manager = NULL;
GdmUserVerifier *user_verifier = NULL;
gboolean ret;
char *address;
g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
- if (client->priv->manager == NULL) {
- client->priv->manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.DisplayManager",
- "/org/gnome/DisplayManager/Manager",
- cancellable,
- error);
+ manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.gnome.DisplayManager",
+ "/org/gnome/DisplayManager/Manager",
+ cancellable,
+ error);
- if (client->priv->manager == NULL) {
- goto out;
- }
- } else {
- client->priv->manager = g_object_ref (client->priv->manager);
+ if (manager == NULL) {
+ goto out;
}
- ret = gdm_manager_call_open_reauthentication_channel_sync (client->priv->manager,
+ ret = gdm_manager_call_open_reauthentication_channel_sync (manager,
username,
&address,
cancellable,
@@ -684,11 +660,6 @@ gdm_client_open_reauthentication_channel_sync (GdmClient *client,
(GWeakNotify)
g_object_unref,
connection);
-
- g_object_weak_ref (G_OBJECT (user_verifier),
- (GWeakNotify)
- g_clear_object,
- &client->priv->manager);
}
out:
@@ -794,11 +765,7 @@ gdm_client_get_user_verifier_sync (GdmClient *client,
g_object_weak_ref (G_OBJECT (client->priv->user_verifier),
(GWeakNotify)
g_clear_object,
- &client->priv->manager);
- g_object_weak_ref (G_OBJECT (client->priv->user_verifier),
- (GWeakNotify)
- g_object_unref,
- client->priv->connection);
+ &client->priv->connection);
if (client->priv->enabled_extensions != NULL) {
gboolean res;
@@ -941,11 +908,6 @@ gdm_client_get_user_verifier_finish (GdmClient *client,
g_object_unref,
client->priv->connection);
- g_object_weak_ref (G_OBJECT (client->priv->user_verifier),
- (GWeakNotify)
- g_clear_object,
- &client->priv->manager);
-
return user_verifier;
}
@@ -1115,12 +1077,6 @@ gdm_client_get_greeter_finish (GdmClient *client,
(GWeakNotify)
g_object_unref,
client->priv->connection);
-
- g_object_weak_ref (G_OBJECT (client->priv->greeter),
- (GWeakNotify)
- g_clear_object,
- &client->priv->manager);
-
return greeter;
}
@@ -1164,11 +1120,7 @@ gdm_client_get_greeter_sync (GdmClient *client,
g_object_weak_ref (G_OBJECT (client->priv->greeter),
(GWeakNotify)
g_clear_object,
- &client->priv->manager);
- g_object_weak_ref (G_OBJECT (client->priv->greeter),
- (GWeakNotify)
- g_object_unref,
- client->priv->connection);
+ &client->priv->connection);
query_for_timed_login_requested_signal (client->priv->greeter);
}
@@ -1301,11 +1253,6 @@ gdm_client_get_remote_greeter_finish (GdmClient *client,
g_object_unref,
client->priv->connection);
- g_object_weak_ref (G_OBJECT (client->priv->remote_greeter),
- (GWeakNotify)
- g_clear_object,
- &client->priv->manager);
-
return remote_greeter;
}
@@ -1348,11 +1295,7 @@ gdm_client_get_remote_greeter_sync (GdmClient *client,
g_object_weak_ref (G_OBJECT (client->priv->remote_greeter),
(GWeakNotify)
g_clear_object,
- &client->priv->manager);
- g_object_weak_ref (G_OBJECT (client->priv->remote_greeter),
- (GWeakNotify)
- g_object_unref,
- client->priv->connection);
+ &client->priv->connection);
}
return client->priv->remote_greeter;
@@ -1483,11 +1426,6 @@ gdm_client_get_chooser_finish (GdmClient *client,
g_object_unref,
client->priv->connection);
- g_object_weak_ref (G_OBJECT (client->priv->chooser),
- (GWeakNotify)
- g_clear_object,
- &client->priv->manager);
-
return chooser;
}
@@ -1531,11 +1469,7 @@ gdm_client_get_chooser_sync (GdmClient *client,
g_object_weak_ref (G_OBJECT (client->priv->chooser),
(GWeakNotify)
g_clear_object,
- &client->priv->manager);
- g_object_weak_ref (G_OBJECT (client->priv->chooser),
- (GWeakNotify)
- g_object_unref,
- client->priv->connection);
+ &client->priv->connection);
}
return client->priv->chooser;
@@ -1601,7 +1535,6 @@ gdm_client_finalize (GObject *object)
&client->priv->connection);
}
- g_clear_object (&client->priv->manager);
g_clear_object (&client->priv->connection);
g_strfreev (client->priv->enabled_extensions);