[libgovirt] Fix setting of OvirtProxy::ssl-ca-file from tmp file
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] Fix setting of OvirtProxy::ssl-ca-file from tmp file
- Date: Tue, 29 Oct 2013 17:02:33 +0000 (UTC)
commit dd5651e56f5f20667b3953df3e736b5afa5267e4
Author: Christophe Fergeau <cfergeau redhat com>
Date: Tue Oct 29 16:14:02 2013 +0100
Fix setting of OvirtProxy::ssl-ca-file from tmp file
We were setting the path for the temporary file using g_object_set,
which triggered a callback listening for ssl-ca-file changes, which
made sure the temp file was removed when ssl-ca-file is modified.
We obviously do not want to do that when we are currently setting
the path to the temporary file we just created, so we just block
this handler while setting it.
govirt/ovirt-proxy-private.h | 2 ++
govirt/ovirt-proxy.c | 13 +++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/govirt/ovirt-proxy-private.h b/govirt/ovirt-proxy-private.h
index c2cbb65..1053ce8 100644
--- a/govirt/ovirt-proxy-private.h
+++ b/govirt/ovirt-proxy-private.h
@@ -34,6 +34,8 @@ struct _OvirtProxyPrivate {
char *tmp_ca_file;
gboolean admin_mode;
OvirtApi *api;
+
+ gulong ssl_ca_file_changed_id;
};
RestXmlNode *ovirt_proxy_get_collection_xml(OvirtProxy *proxy,
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 85a3c0e..ef18dc7 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -442,7 +442,13 @@ static void ovirt_proxy_set_tmp_ca_file(OvirtProxy *proxy, const char *ca_file)
}
proxy->priv->tmp_ca_file = g_strdup(ca_file);
if (ca_file != NULL) {
+ /* Not blocking this signal would cause the callback to call again
+ * set_tmp_ca_file with a NULL ca_file, undoing the work we just did */
+ g_signal_handler_block(G_OBJECT(proxy),
+ proxy->priv->ssl_ca_file_changed_id);
g_object_set(G_OBJECT(proxy), "ssl-ca-file", ca_file, NULL);
+ g_signal_handler_unblock(G_OBJECT(proxy),
+ proxy->priv->ssl_ca_file_changed_id);
}
}
@@ -778,10 +784,13 @@ static void ssl_ca_file_changed(GObject *gobject,
static void
ovirt_proxy_init(OvirtProxy *self)
{
+ gulong handler_id;
+
self->priv = OVIRT_PROXY_GET_PRIVATE(self);
- g_signal_connect(G_OBJECT(self), "notify::ssl-ca-file",
- (GCallback)ssl_ca_file_changed, NULL);
+ handler_id = g_signal_connect(G_OBJECT(self), "notify::ssl-ca-file",
+ (GCallback)ssl_ca_file_changed, NULL);
+ self->priv->ssl_ca_file_changed_id = handler_id;
}
OvirtProxy *ovirt_proxy_new(const char *uri)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]