[libvirt] [PATCH] Fix ref-counting for Xen driver event registration

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

 



# HG changeset patch
# User john.levon@xxxxxxx
# Date 1231958879 28800
# Node ID 46dc909bda5b20d11f08d1516f21c05f27b6648f
# Parent  1fca4b0dd4c6ab3c0030b4986de6fe5cb7c94631
Fix ref-counting for Xen driver event registration

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/src/xen_unified.c b/src/xen_unified.c
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -1359,15 +1359,21 @@ xenUnifiedDomainEventRegister (virConnec
                                void *opaque,
                                void (*freefunc)(void *))
 {
+    int ret;
+
     GET_PRIVATE (conn);
     if (priv->xsWatch == -1) {
         xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
         return -1;
     }
 
-    conn->refs++;
-    return virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
-                                         callback, opaque, freefunc);
+    ret = virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
+        callback, opaque, freefunc);
+
+    if (ret == 0)
+        conn->refs++;
+
+    return (ret);
 }
 
 static int
@@ -1382,8 +1388,10 @@ xenUnifiedDomainEventDeregister (virConn
     }
 
     ret = virDomainEventCallbackListRemove(conn, priv->domainEventCallbacks,
-                                            callback);
-    virUnrefConnect(conn);
+        callback);
+
+    if (ret == 0)
+        virUnrefConnect(conn);
     return ret;
 }
 

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]