mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +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()))
|
||||
return NULL;
|
||||
|
||||
chDriverLock(driver);
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&driver->lock) {
|
||||
if (refresh) {
|
||||
virObjectUnref(driver->caps);
|
||||
driver->caps = caps;
|
||||
}
|
||||
|
||||
if (refresh) {
|
||||
virObjectUnref(driver->caps);
|
||||
driver->caps = caps;
|
||||
ret = virObjectRef(driver->caps);
|
||||
}
|
||||
|
||||
ret = virObjectRef(driver->caps);
|
||||
chDriverUnlock(driver);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -159,11 +158,8 @@ virCHDriverConfigNew(bool privileged)
|
||||
|
||||
virCHDriverConfig *virCHDriverGetConfig(virCHDriver *driver)
|
||||
{
|
||||
virCHDriverConfig *cfg;
|
||||
chDriverLock(driver);
|
||||
cfg = virObjectRef(driver->config);
|
||||
chDriverUnlock(driver);
|
||||
return cfg;
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&driver->lock);
|
||||
return virObjectRef(driver->config);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -78,13 +78,3 @@ virDomainXMLOption *chDomainXMLConfInit(virCHDriver *driver);
|
||||
virCHDriverConfig *virCHDriverConfigNew(bool privileged);
|
||||
virCHDriverConfig *virCHDriverGetConfig(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…
x
Reference in New Issue
Block a user