libvirt: Increase connection reference count for callbacks

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

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
This commit is contained in:
Viktor Mihajlovski 2013-03-26 10:54:53 +01:00 committed by Peter Krempa
parent 482e5f159c
commit 03a43efa86

View File

@ -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: