mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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:
parent
482e5f159c
commit
03a43efa86
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user