[libgovirt] proxy: Don't set RestProxy::ssl-ca-file from finalize



commit f0a7632007b2604c125d591d91258033d9227fd0
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Jul 28 10:22:25 2015 +0200

    proxy: Don't set RestProxy::ssl-ca-file from finalize
    
    In OvirtProxy::finalize(), we need to cleanup the temp file we created.
    However, we don't really need to set the RestProxy::ssl-ca-file
    property as the object is dying. This commit splits the code removing
    the temp file out of ovirt_proxy_set_tmp_ca_file().

 govirt/ovirt-proxy.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 28a50bc..8f3e3d2 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -427,7 +427,7 @@ static GByteArray *get_ca_cert_data(OvirtProxy *proxy)
     return g_byte_array_new_take((guchar *)content, length);
 }
 
-static void ovirt_proxy_set_tmp_ca_file(OvirtProxy *proxy, const char *ca_file)
+static void ovirt_proxy_free_tmp_ca_file(OvirtProxy *proxy)
 {
     if (proxy->priv->tmp_ca_file != NULL) {
         int unlink_failed;
@@ -436,7 +436,13 @@ static void ovirt_proxy_set_tmp_ca_file(OvirtProxy *proxy, const char *ca_file)
             g_warning("Failed to unlink '%s'", proxy->priv->tmp_ca_file);
         }
         g_free(proxy->priv->tmp_ca_file);
+        proxy->priv->tmp_ca_file = NULL;
     }
+}
+
+static void ovirt_proxy_set_tmp_ca_file(OvirtProxy *proxy, const char *ca_file)
+{
+    ovirt_proxy_free_tmp_ca_file(proxy);
     proxy->priv->tmp_ca_file = g_strdup(ca_file);
     if (ca_file != NULL) {
         /* Not blocking this signal would cause the callback to call again
@@ -846,7 +852,7 @@ ovirt_proxy_finalize(GObject *obj)
 {
     OvirtProxy *proxy = OVIRT_PROXY(obj);
 
-    ovirt_proxy_set_tmp_ca_file(proxy, NULL);
+    ovirt_proxy_free_tmp_ca_file(proxy);
     g_free(proxy->priv->jsessionid);
 
     G_OBJECT_CLASS(ovirt_proxy_parent_class)->finalize(obj);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]