]> xenbits.xensource.com Git - libvirt.git/commitdiff
nwfilter: Fix memory leak in the ebtables subdriver
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 30 Apr 2011 10:23:31 +0000 (12:23 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 30 Apr 2011 15:37:54 +0000 (17:37 +0200)
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.

src/conf/nwfilter_conf.c
src/nwfilter/nwfilter_driver.c
src/nwfilter/nwfilter_learnipaddr.c

index 09dc32b3772f4c591ce839d04ecfc8214f918d64..615c0f1983e209aa1c65eba1eafab5c9fb189af9 100644 (file)
@@ -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;
 }
 
 
index a5793062dab3968e354621369d293ae447f77e74..8af3f8ab22a786225685f08252f0ee69cb79f4d7 100644 (file)
@@ -199,6 +199,8 @@ nwfilterDriverShutdown(void) {
     if (!driverState)
         return -1;
 
+    virNWFilterConfLayerShutdown();
+    virNWFilterTechDriversShutdown();
     virNWFilterLearnShutdown();
 
     nwfilterDriverLock(driverState);
index 9ee439a102cec7f14c0fb8f798beae5409cb562c..96d2a55b0eb5197584c534196b2497a0d63ac576 100644 (file)
@@ -873,7 +873,10 @@ virNWFilterLearnThreadsTerminate(bool allowNewThreads) {
  * Shutdown of this layer
  */
 void
-virNWFilterLearnShutdown(void) {
+virNWFilterLearnShutdown(void)
+{
+    if (!pendingLearnReq)
+        return;
 
     virNWFilterLearnThreadsTerminate(false);