[libvirt] [PATCH v4 2/9] virConnectCloseCallbackData: fix connection object refcount

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Fri Feb 5 13:44:31 UTC 2016


We have reference to connection object in virConnectCloseCallbackData
object thus we have to refcount it. Obviously we have problems
in dispose and call functions. Let's fix it.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
---
 src/datatypes.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/datatypes.c b/src/datatypes.c
index 030a0d2..a4ee2b8 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -176,6 +176,7 @@ virConnectCloseCallbackDataDispose(void *obj)
 
     if (cb->freeCallback)
         cb->freeCallback(cb->opaque);
+    virObjectUnref(cb->conn);
 
     virObjectUnlock(cb);
 }
@@ -222,6 +223,7 @@ void virConnectCloseCallbackDataUnregister(virConnectCloseCallbackDataPtr close,
         close->freeCallback(close->opaque);
     close->freeCallback = NULL;
     virObjectUnref(close->conn);
+    close->conn = NULL;
 
  cleanup:
 
@@ -244,6 +246,8 @@ void virConnectCloseCallbackDataCall(virConnectCloseCallbackDataPtr close,
         close->freeCallback(close->opaque);
     close->callback = NULL;
     close->freeCallback = NULL;
+    virObjectUnref(close->conn);
+    close->conn = NULL;
 
  exit:
     virObjectUnlock(close);
-- 
1.8.3.1




More information about the libvir-list mailing list