mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
nwfilter: Fix memory leak in the ebtables subdriver
Call shutdown functions for all subcomponents in nwfilterDriverShutdown. Make sure that this shutdown functions can safely be called multiple times and independent from the actual subcomponents state.
This commit is contained in:
@@ -125,6 +125,7 @@ struct int_map {
|
||||
* only one filter update allowed
|
||||
*/
|
||||
static virMutex updateMutex;
|
||||
static bool initialized = false;
|
||||
|
||||
void
|
||||
virNWFilterLockFilterUpdates(void) {
|
||||
@@ -2971,6 +2972,8 @@ int virNWFilterConfLayerInit(virHashIterator domUpdateCB)
|
||||
{
|
||||
virNWFilterDomainFWUpdateCB = domUpdateCB;
|
||||
|
||||
initialized = true;
|
||||
|
||||
if (virMutexInitRecursive(&updateMutex))
|
||||
return 1;
|
||||
|
||||
@@ -2980,7 +2983,12 @@ int virNWFilterConfLayerInit(virHashIterator domUpdateCB)
|
||||
|
||||
void virNWFilterConfLayerShutdown(void)
|
||||
{
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
virMutexDestroy(&updateMutex);
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -199,6 +199,8 @@ nwfilterDriverShutdown(void) {
|
||||
if (!driverState)
|
||||
return -1;
|
||||
|
||||
virNWFilterConfLayerShutdown();
|
||||
virNWFilterTechDriversShutdown();
|
||||
virNWFilterLearnShutdown();
|
||||
|
||||
nwfilterDriverLock(driverState);
|
||||
|
||||
@@ -873,7 +873,10 @@ virNWFilterLearnThreadsTerminate(bool allowNewThreads) {
|
||||
* Shutdown of this layer
|
||||
*/
|
||||
void
|
||||
virNWFilterLearnShutdown(void) {
|
||||
virNWFilterLearnShutdown(void)
|
||||
{
|
||||
if (!pendingLearnReq)
|
||||
return;
|
||||
|
||||
virNWFilterLearnThreadsTerminate(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user