mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
ch: Prepare virCHDriverGetCapabilities for automatic mutex management
No functional change intended. This change makes the refactoring to automatic mutex management easier to follow. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
241c13a7e5
commit
0a6ff46c9e
@ -87,21 +87,22 @@ virCaps *virCHDriverCapsInit(void)
|
|||||||
virCaps *virCHDriverGetCapabilities(virCHDriver *driver,
|
virCaps *virCHDriverGetCapabilities(virCHDriver *driver,
|
||||||
bool refresh)
|
bool refresh)
|
||||||
{
|
{
|
||||||
virCaps *ret;
|
virCaps *ret = NULL;
|
||||||
if (refresh) {
|
virCaps *caps = NULL;
|
||||||
virCaps *caps = NULL;
|
|
||||||
if ((caps = virCHDriverCapsInit()) == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
chDriverLock(driver);
|
if (refresh && !(caps = virCHDriverCapsInit()))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
chDriverLock(driver);
|
||||||
|
|
||||||
|
if (refresh) {
|
||||||
virObjectUnref(driver->caps);
|
virObjectUnref(driver->caps);
|
||||||
driver->caps = caps;
|
driver->caps = caps;
|
||||||
} else {
|
|
||||||
chDriverLock(driver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virObjectRef(driver->caps);
|
ret = virObjectRef(driver->caps);
|
||||||
chDriverUnlock(driver);
|
chDriverUnlock(driver);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user