From: John Ferlan <jferlan(a)redhat.com>
Now that nwfilters object list is self locking, it's no longer
necessary to hold the driver level lock for certain API's.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/nwfilter/nwfilter_driver.c | 47 +++++++++++-------------------------------
1 file changed, 12 insertions(+), 35 deletions(-)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 093844c9e..d49c32e4c 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -295,6 +295,10 @@ nwfilterStateReload(void)
/* shut down all threads -- they will be restarted if necessary */
virNWFilterLearnThreadsTerminate(true);
+ /* Serialization of virNWFilterObjListLoadAllConfigs is extremely
+ * important as it relates to virNWFilterObjListFindInstantiateFilter
+ * processing via virNWFilterTriggerVMFilterRebuild that occurs during
+ * virNWFilterObjListAssignDef */
nwfilterDriverLock();
virNWFilterWriteLockFilterUpdates();
virNWFilterCallbackDriversLock();
@@ -452,11 +456,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
virNWFilterDefPtr def;
virNWFilterPtr nwfilter = NULL;
- nwfilterDriverLock();
- obj = nwfilterObjFromNWFilter(uuid);
- nwfilterDriverUnlock();
-
- if (!obj)
+ if (!(obj = nwfilterObjFromNWFilter(uuid)))
return NULL;
def = virNWFilterObjGetDef(obj);
@@ -479,11 +479,7 @@ nwfilterLookupByName(virConnectPtr conn,
virNWFilterDefPtr def;
virNWFilterPtr nwfilter = NULL;
- nwfilterDriverLock();
- obj = virNWFilterObjListFindByName(driver->nwfilters, name);
- nwfilterDriverUnlock();
-
- if (!obj) {
+ if (!(obj = virNWFilterObjListFindByName(driver->nwfilters, name))) {
virReportError(VIR_ERR_NO_NWFILTER,
_("no nwfilter with matching name '%s'"),
name);
return NULL;
@@ -517,17 +513,12 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
char **const names,
int maxnames)
{
- int nnames;
-
if (virConnectListNWFiltersEnsureACL(conn) < 0)
return -1;
- nwfilterDriverLock();
- nnames = virNWFilterObjListGetNames(driver->nwfilters, conn,
- virConnectListNWFiltersCheckACL,
- names, maxnames);
- nwfilterDriverUnlock();
- return nnames;
+ return virNWFilterObjListGetNames(driver->nwfilters, conn,
+ virConnectListNWFiltersCheckACL,
+ names, maxnames);
}
@@ -536,19 +527,13 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
virNWFilterPtr **nwfilters,
unsigned int flags)
{
- int ret;
-
virCheckFlags(0, -1);
if (virConnectListAllNWFiltersEnsureACL(conn) < 0)
return -1;
- nwfilterDriverLock();
- ret = virNWFilterObjListExport(conn, driver->nwfilters, nwfilters,
- virConnectListAllNWFiltersCheckACL);
- nwfilterDriverUnlock();
-
- return ret;
+ return virNWFilterObjListExport(conn, driver->nwfilters, nwfilters,
+ virConnectListAllNWFiltersCheckACL);
}
static virNWFilterPtr
@@ -566,7 +551,6 @@ nwfilterDefineXML(virConnectPtr conn,
return NULL;
}
- nwfilterDriverLock();
virNWFilterWriteLockFilterUpdates();
virNWFilterCallbackDriversLock();
@@ -594,7 +578,6 @@ nwfilterDefineXML(virConnectPtr conn,
virNWFilterCallbackDriversUnlock();
virNWFilterUnlockFilterUpdates();
- nwfilterDriverUnlock();
return nwfilter;
}
@@ -606,7 +589,6 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
virNWFilterDefPtr def;
int ret = -1;
- nwfilterDriverLock();
virNWFilterWriteLockFilterUpdates();
virNWFilterCallbackDriversLock();
@@ -634,7 +616,6 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
virNWFilterObjEndAPI(&obj);
virNWFilterCallbackDriversUnlock();
virNWFilterUnlockFilterUpdates();
- nwfilterDriverUnlock();
return ret;
}
@@ -649,11 +630,7 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
virCheckFlags(0, NULL);
- nwfilterDriverLock();
- obj = nwfilterObjFromNWFilter(nwfilter->uuid);
- nwfilterDriverUnlock();
-
- if (!obj)
+ if (!(obj = nwfilterObjFromNWFilter(nwfilter->uuid)))
return NULL;
def = virNWFilterObjGetDef(obj);
--
2.13.6