From: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
By adjusting the reference count of the connection object we
prevent races between callback function and virConnectClose.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/libvirt.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/libvirt.c b/src/libvirt.c
index 4b9ea75..e9aff8a 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.8.1.5