mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
ch: Use automatic mutex management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
0a6ff46c9e
commit
6f3c0480b1
@ -93,16 +93,15 @@ virCaps *virCHDriverGetCapabilities(virCHDriver *driver,
|
|||||||
if (refresh && !(caps = virCHDriverCapsInit()))
|
if (refresh && !(caps = virCHDriverCapsInit()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
chDriverLock(driver);
|
VIR_WITH_MUTEX_LOCK_GUARD(&driver->lock) {
|
||||||
|
if (refresh) {
|
||||||
|
virObjectUnref(driver->caps);
|
||||||
|
driver->caps = caps;
|
||||||
|
}
|
||||||
|
|
||||||
if (refresh) {
|
ret = virObjectRef(driver->caps);
|
||||||
virObjectUnref(driver->caps);
|
|
||||||
driver->caps = caps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virObjectRef(driver->caps);
|
|
||||||
chDriverUnlock(driver);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,11 +158,8 @@ virCHDriverConfigNew(bool privileged)
|
|||||||
|
|
||||||
virCHDriverConfig *virCHDriverGetConfig(virCHDriver *driver)
|
virCHDriverConfig *virCHDriverGetConfig(virCHDriver *driver)
|
||||||
{
|
{
|
||||||
virCHDriverConfig *cfg;
|
VIR_LOCK_GUARD lock = virLockGuardLock(&driver->lock);
|
||||||
chDriverLock(driver);
|
return virObjectRef(driver->config);
|
||||||
cfg = virObjectRef(driver->config);
|
|
||||||
chDriverUnlock(driver);
|
|
||||||
return cfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -78,13 +78,3 @@ virDomainXMLOption *chDomainXMLConfInit(virCHDriver *driver);
|
|||||||
virCHDriverConfig *virCHDriverConfigNew(bool privileged);
|
virCHDriverConfig *virCHDriverConfigNew(bool privileged);
|
||||||
virCHDriverConfig *virCHDriverGetConfig(virCHDriver *driver);
|
virCHDriverConfig *virCHDriverGetConfig(virCHDriver *driver);
|
||||||
int chExtractVersion(virCHDriver *driver);
|
int chExtractVersion(virCHDriver *driver);
|
||||||
|
|
||||||
static inline void chDriverLock(virCHDriver *driver)
|
|
||||||
{
|
|
||||||
virMutexLock(&driver->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void chDriverUnlock(virCHDriver *driver)
|
|
||||||
{
|
|
||||||
virMutexUnlock(&driver->lock);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user