[ovs-dev] [memory fixes 6/6] ovs-vswitchd: Release most memory on normal exit.

Ben Pfaff blp at nicira.com
Mon Dec 13 21:10:51 UTC 2010


This makes "valgrind --leak-check=full --show-reachable=yes" output much
easier to read.
---
 vswitchd/bridge.c       |   11 +++++++++++
 vswitchd/bridge.h       |    7 ++-----
 vswitchd/ovs-vswitchd.c |    2 ++
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 130f65e..09f5200 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -317,6 +317,17 @@ bridge_init(const char *remote)
     bond_init();
 }
 
+void
+bridge_exit(void)
+{
+    struct bridge *br, *next_br;
+
+    LIST_FOR_EACH_SAFE (br, next_br, node, &all_bridges) {
+        bridge_destroy(br);
+    }
+    ovsdb_idl_destroy(idl);
+}
+
 /* Performs configuration that is only necessary once at ovs-vswitchd startup,
  * but for which the ovs-vswitchd configuration 'cfg' is required. */
 static void
diff --git a/vswitchd/bridge.h b/vswitchd/bridge.h
index 42ba4e5..32b581e 100644
--- a/vswitchd/bridge.h
+++ b/vswitchd/bridge.h
@@ -16,12 +16,9 @@
 #ifndef VSWITCHD_BRIDGE_H
 #define VSWITCHD_BRIDGE_H 1
 
-#include <stdbool.h>
-#include <stdint.h>
-
-struct svec;
-
 void bridge_init(const char *remote);
+void bridge_exit(void);
+
 void bridge_run(void);
 void bridge_wait(void);
 
diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c
index 93f0371..cd30c96 100644
--- a/vswitchd/ovs-vswitchd.c
+++ b/vswitchd/ovs-vswitchd.c
@@ -107,6 +107,8 @@ main(int argc, char *argv[])
         }
         poll_block();
     }
+    bridge_exit();
+    unixctl_server_destroy(unixctl);
 
     return 0;
 }
-- 
1.7.1





More information about the dev mailing list