[glib-networking/tls-database] gnutls: Delay loading of GTlsConnectionGnutls:database
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/tls-database] gnutls: Delay loading of GTlsConnectionGnutls:database
- Date: Tue, 28 Dec 2010 16:32:32 +0000 (UTC)
commit 233bed125f68e06c15d3d16452261834eba5a3cc
Author: Stef Walter <stefw collabora co uk>
Date: Tue Dec 28 10:29:47 2010 -0600
gnutls: Delay loading of GTlsConnectionGnutls:database
Don't load the default database until after the first time it's requested.
This matches the earlier behavior of not parsing the CA certs file
until when it's needed.
tls/gnutls/gtlsbackend-gnutls.c | 1 +
tls/gnutls/gtlsconnection-gnutls.c | 15 ++++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c
index 5028bdb..75b3e93 100644
--- a/tls/gnutls/gtlsbackend-gnutls.c
+++ b/tls/gnutls/gtlsbackend-gnutls.c
@@ -193,6 +193,7 @@ g_tls_backend_gnutls_get_default_database (GTlsBackend *backend)
return result;
}
+
static void
g_tls_backend_gnutls_interface_init (GTlsBackendInterface *iface)
{
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 2937996..20cb500 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -118,6 +118,7 @@ struct _GTlsConnectionGnutlsPrivate
gboolean require_close_notify;
GTlsRehandshakeMode rehandshake_mode;
GTlsDatabase *database;
+ gboolean database_is_unset;
gboolean need_handshake, handshaking, ever_handshaked;
gboolean closing;
@@ -171,8 +172,6 @@ g_tls_connection_gnutls_initable_iface_init (GInitableIface *iface)
static void
g_tls_connection_gnutls_init (GTlsConnectionGnutls *gnutls)
{
- GTlsBackend *backend;
-
gnutls->priv = G_TYPE_INSTANCE_GET_PRIVATE (gnutls, G_TYPE_TLS_CONNECTION_GNUTLS, GTlsConnectionGnutlsPrivate);
gnutls_certificate_allocate_credentials (&gnutls->priv->creds);
@@ -180,9 +179,7 @@ g_tls_connection_gnutls_init (GTlsConnectionGnutls *gnutls)
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
gnutls->priv->need_handshake = TRUE;
-
- backend = g_tls_backend_get_default ();
- gnutls->priv->database = g_tls_backend_get_default_database (backend);
+ gnutls->priv->database_is_unset = TRUE;
}
static gnutls_priority_t priorities[2][2];
@@ -298,6 +295,7 @@ g_tls_connection_gnutls_get_property (GObject *object,
GParamSpec *pspec)
{
GTlsConnectionGnutls *gnutls = G_TLS_CONNECTION_GNUTLS (object);
+ GTlsBackend *backend;
switch (prop_id)
{
@@ -314,6 +312,12 @@ g_tls_connection_gnutls_get_property (GObject *object,
break;
case PROP_DATABASE:
+ if (gnutls->priv->database_is_unset)
+ {
+ backend = g_tls_backend_get_default ();
+ gnutls->priv->database = g_tls_backend_get_default_database (backend);
+ gnutls->priv->database_is_unset = FALSE;
+ }
g_value_set_object (value, gnutls->priv->database);
break;
@@ -378,6 +382,7 @@ g_tls_connection_gnutls_set_property (GObject *object,
case PROP_DATABASE:
gnutls->priv->database = g_value_dup_object (value);
+ gnutls->priv->database_is_unset = FALSE;
break;
case PROP_CERTIFICATE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]