DPDK documentation is recently updated to reflect that DPDK does not
hold any references to, nor take ownership of, the argv/argc elements.
With that understanding, let's just release the memory asap.

Signed-off-by: Aaron Conole <[email protected]>
---
NOTE: if the patch at
      http://dpdk.org/ml/archives/dev/2016-December/051812.html is
      accepted, then consider this non-RFC.
 lib/dpdk.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/lib/dpdk.c b/lib/dpdk.c
index 28f3485..ee4360b 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -250,11 +250,8 @@ get_dpdk_args(const struct smap *ovs_other_config, char 
***argv,
     return i + extra_argc;
 }
 
-static char **dpdk_argv, **dpdk_argv_release;
-static int dpdk_argc;
-
 static void
-deferred_argv_release(void)
+argv_release(char **dpdk_argv, char **dpdk_argv_release, size_t dpdk_argc)
 {
     int result;
     for (result = 0; result < dpdk_argc; ++result) {
@@ -268,7 +265,7 @@ deferred_argv_release(void)
 static void
 dpdk_init__(const struct smap *ovs_other_config)
 {
-    char **argv = NULL;
+    char **argv = NULL, **argv_to_release = NULL;
     int result;
     int argc, argc_tmp;
     bool auto_determine = true;
@@ -367,9 +364,9 @@ dpdk_init__(const struct smap *ovs_other_config)
         ds_destroy(&eal_args);
     }
 
-    dpdk_argv_release = grow_argv(&dpdk_argv_release, 0, argc);
+    argv_to_release = grow_argv(&argv_to_release, 0, argc);
     for (argc_tmp = 0; argc_tmp < argc; ++argc_tmp) {
-        dpdk_argv_release[argc_tmp] = argv[argc_tmp];
+        argv_to_release[argc_tmp] = argv[argc_tmp];
     }
 
     /* Make sure things are initialized ... */
@@ -377,6 +374,7 @@ dpdk_init__(const struct smap *ovs_other_config)
     if (result < 0) {
         ovs_abort(result, "Cannot init EAL");
     }
+    argv_release(argv, argv_to_release, argc);
 
     /* Set the main thread affinity back to pre rte_eal_init() value */
     if (auto_determine && !err) {
@@ -387,11 +385,6 @@ dpdk_init__(const struct smap *ovs_other_config)
         }
     }
 
-    dpdk_argv = argv;
-    dpdk_argc = argc;
-
-    atexit(deferred_argv_release);
-
     rte_memzone_dump(stdout);
 
     /* We are called from the main thread here */
-- 
2.7.4

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to