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:
Tim Wiederhake 2022-02-04 16:11:49 +01:00
parent 241c13a7e5
commit 0a6ff46c9e

View File

@ -87,21 +87,22 @@ virCaps *virCHDriverCapsInit(void)
virCaps *virCHDriverGetCapabilities(virCHDriver *driver,
bool refresh)
{
virCaps *ret;
if (refresh) {
virCaps *caps = NULL;
if ((caps = virCHDriverCapsInit()) == NULL)
return NULL;
virCaps *ret = NULL;
virCaps *caps = NULL;
chDriverLock(driver);
if (refresh && !(caps = virCHDriverCapsInit()))
return NULL;
chDriverLock(driver);
if (refresh) {
virObjectUnref(driver->caps);
driver->caps = caps;
} else {
chDriverLock(driver);
}
ret = virObjectRef(driver->caps);
chDriverUnlock(driver);
return ret;
}