[PATCH 1/3] libvirt: Increase connection reference count for callbacks

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

 



By adjusting the reference count of the connection object we
prevent races between callback function and virConnectClose.

Signed-off-by: Viktor Mihajlovski <mihajlov@xxxxxxxxxxxxxxxxxx>
---
 src/libvirt.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/libvirt.c b/src/libvirt.c
index 1624776..1aed2b4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -20186,6 +20186,8 @@ int virConnectRegisterCloseCallback(virConnectPtr conn,
         return -1;
     }
 
+    virObjectRef(conn);
+
     virMutexLock(&conn->lock);
 
     virCheckNonNullArgGoto(cb, error);
@@ -20206,6 +20208,7 @@ int virConnectRegisterCloseCallback(virConnectPtr conn,
 
 error:
     virMutexUnlock(&conn->lock);
+    virObjectUnref(conn);
     virDispatchError(NULL);
     return -1;
 }
@@ -20255,6 +20258,8 @@ int virConnectUnregisterCloseCallback(virConnectPtr conn,
 
     virMutexUnlock(&conn->lock);
 
+    virObjectUnref(conn);
+
     return 0;
 
 error:
-- 
1.7.9.5

--
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]