提交 8cc166e7 编写于 作者: S Stefan Berger

nwfilter: reorder locks

This patch reorders the locks for the nwfilter updates and the access
the nwfilter objects. In the case that the IP address learning thread
was instantiating filters while an update happened, the previous order
lead to a deadlock.
上级 ecbe86c0
......@@ -2394,15 +2394,13 @@ virNWFilterTestUnassignDef(virConnectPtr conn,
{
int rc = 0;
virNWFilterLockFilterUpdates();
nwfilter->wantRemoved = 1;
/* trigger the update on VMs referencing the filter */
if (virNWFilterTriggerVMFilterRebuild(conn))
rc = 1;
nwfilter->wantRemoved = 0;
virNWFilterUnlockFilterUpdates();
return rc;
}
......@@ -2434,8 +2432,9 @@ virNWFilterObjAssignDef(virConnectPtr conn,
return NULL;
}
virNWFilterLockFilterUpdates();
if ((nwfilter = virNWFilterObjFindByName(nwfilters, def->name))) {
virNWFilterLockFilterUpdates();
nwfilter->newDef = def;
/* trigger the update on VMs referencing the filter */
if (virNWFilterTriggerVMFilterRebuild(conn)) {
......@@ -2452,6 +2451,8 @@ virNWFilterObjAssignDef(virConnectPtr conn,
return nwfilter;
}
virNWFilterUnlockFilterUpdates();
if (VIR_ALLOC(nwfilter) < 0) {
virReportOOMError();
return NULL;
......
......@@ -372,6 +372,8 @@ nwfilterUndefine(virNWFilterPtr obj) {
nwfilterDriverLock(driver);
virNWFilterCallbackDriversLock();
virNWFilterLockFilterUpdates();
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
......@@ -399,6 +401,8 @@ cleanup:
if (nwfilter)
virNWFilterObjUnlock(nwfilter);
virNWFilterUnlockFilterUpdates();
virNWFilterCallbackDriversUnlock();
nwfilterDriverUnlock(driver);
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册