Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 33 +++++++++-----------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 7bbf1e12fb..a8c0c6aa22 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -717,9 +717,7 @@ virNWFilterInstantiateFilterInternal(virNWFilterDriverState *driver,
bool *foundNewFilter)
{
int ifindex;
- int rc;
-
- virMutexLock(&updateMutex);
+ VIR_LOCK_GUARD lock = virLockGuardLock(&updateMutex);
/* after grabbing the filter update lock check for the interface; if
it's not there anymore its filters will be or are being removed
@@ -729,20 +727,14 @@ virNWFilterInstantiateFilterInternal(virNWFilterDriverState
*driver,
/* interfaces / VMs can disappear during filter instantiation;
don't mark it as an error */
virResetLastError();
- rc = 0;
- goto cleanup;
+ return 0;
}
- rc = virNWFilterInstantiateFilterUpdate(driver, teardownOld,
- binding,
- ifindex,
- useNewFilter,
- false, foundNewFilter);
-
- cleanup:
- virMutexUnlock(&updateMutex);
-
- return rc;
+ return virNWFilterInstantiateFilterUpdate(driver, teardownOld,
+ binding,
+ ifindex,
+ useNewFilter,
+ false, foundNewFilter);
}
@@ -753,9 +745,9 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverState *driver,
{
int rc;
bool foundNewFilter = false;
+ VIR_LOCK_GUARD lock = virLockGuardLock(&updateMutex);
virNWFilterReadLockFilterUpdates();
- virMutexLock(&updateMutex);
rc = virNWFilterInstantiateFilterUpdate(driver, true,
binding, ifindex,
@@ -772,7 +764,6 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverState *driver,
}
virNWFilterUnlockFilterUpdates();
- virMutexUnlock(&updateMutex);
return rc;
}
@@ -894,11 +885,9 @@ _virNWFilterTeardownFilter(const char *ifname)
int
virNWFilterTeardownFilter(virNWFilterBindingDef *binding)
{
- int ret;
- virMutexLock(&updateMutex);
- ret = _virNWFilterTeardownFilter(binding->portdevname);
- virMutexUnlock(&updateMutex);
- return ret;
+ VIR_LOCK_GUARD lock = virLockGuardLock(&updateMutex);
+
+ return _virNWFilterTeardownFilter(binding->portdevname);
}
enum {
--
2.31.1