[gnome-keyring] dbus: don't initialize aliases lazily
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] dbus: don't initialize aliases lazily
- Date: Mon, 31 Aug 2015 21:58:29 +0000 (UTC)
commit 28ff2955d733f137d7fec22f91b65b9a36bff54c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Aug 31 14:54:08 2015 -0700
dbus: don't initialize aliases lazily
Since we call gkd_secret_service_get_alias() from a worker thread, we
should not modify the aliases hash table, or doing I/O from there.
Just initialize the aliases hash table during construction.
daemon/dbus/gkd-secret-service.c | 46 +++++++++++++------------------------
1 files changed, 16 insertions(+), 30 deletions(-)
---
diff --git a/daemon/dbus/gkd-secret-service.c b/daemon/dbus/gkd-secret-service.c
index 89fef19..69a42b4 100644
--- a/daemon/dbus/gkd-secret-service.c
+++ b/daemon/dbus/gkd-secret-service.c
@@ -198,6 +198,9 @@ update_default (GkdSecretService *self)
}
}
+ /* Default to to 'login' if no default keyring */
+ if (contents == NULL)
+ contents = g_strdup ("login");
g_hash_table_replace (self->aliases, g_strdup ("default"), contents);
}
@@ -947,6 +950,17 @@ gkd_secret_service_init_collections (GkdSecretService *self)
g_strfreev (collections);
}
+static void
+gkd_secret_service_init_aliases (GkdSecretService *self)
+{
+ self->aliases = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ g_hash_table_insert (self->aliases, g_strdup ("session"), g_strdup ("session"));
+ /* TODO: We should be using CKA_G_LOGIN_COLLECTION */
+ g_hash_table_insert (self->aliases, g_strdup ("login"), g_strdup ("login"));
+
+ update_default (self);
+}
+
static GObject*
gkd_secret_service_constructor (GType type,
guint n_props,
@@ -1042,8 +1056,8 @@ static void
gkd_secret_service_init (GkdSecretService *self)
{
self->clients = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, free_client);
- self->aliases = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
self->default_path = get_default_path ();
+ gkd_secret_service_init_aliases (self);
}
static void
@@ -1327,38 +1341,10 @@ gkd_secret_service_close_session (GkdSecretService *self, GkdSecretSession *sess
const gchar*
gkd_secret_service_get_alias (GkdSecretService *self, const gchar *alias)
{
- const gchar *identifier;
-
g_return_val_if_fail (GKD_SECRET_IS_SERVICE (self), NULL);
g_return_val_if_fail (alias != NULL, NULL);
- identifier = g_hash_table_lookup (self->aliases, alias);
- if (!identifier) {
- if (g_str_equal (alias, "default")) {
- update_default (self);
- identifier = g_hash_table_lookup (self->aliases, alias);
-
- /* Default to to 'login' if no default keyring */
- if (identifier == NULL) {
- identifier = "login";
- g_hash_table_replace (self->aliases, g_strdup (alias),
- g_strdup (identifier));
- }
-
- } else if (g_str_equal (alias, "session")) {
- identifier = "session";
- g_hash_table_replace (self->aliases, g_strdup (alias),
- g_strdup (identifier));
-
- /* TODO: We should be using CKA_G_LOGIN_COLLECTION */
- } else if (g_str_equal (alias, "login")) {
- identifier = "login";
- g_hash_table_replace (self->aliases, g_strdup (alias),
- g_strdup (identifier));
- }
- }
-
- return identifier;
+ return g_hash_table_lookup (self->aliases, alias);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]