]> git.droids-corp.org - dpdk.git/commitdiff
log: close in cleanup stage
authorStephen Hemminger <stephen@networkplumber.org>
Sat, 13 Nov 2021 17:22:53 +0000 (09:22 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 11 Feb 2022 18:49:22 +0000 (19:49 +0100)
When application calls rte_eal_cleanup on shutdown,
the DPDK log should be closed and cleaned up.

This helps reduce false reports from tools like ASAN
and valgrind that track memory leaks.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/eal/common/eal_common_log.c
lib/eal/common/eal_private.h
lib/eal/linux/eal.c
lib/eal/linux/eal_log.c

index 1be35f5397274a1fc26bc782731923a8020e4061..cbd0b851f216128f16e912ee9af178656bc36743 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_per_lcore.h>
 
 #include "eal_log.h"
+#include "eal_private.h"
 
 struct rte_log_dynamic_type {
        const char *name;
@@ -535,3 +536,15 @@ eal_log_set_default(FILE *default_log)
                "Debug dataplane logs available - lower performance\n");
 #endif
 }
+
+/*
+ * Called by eal_cleanup
+ */
+void
+rte_eal_log_cleanup(void)
+{
+       if (default_log_stream) {
+               fclose(default_log_stream);
+               default_log_stream = NULL;
+       }
+}
index 734f1f334b696906731f86645cbcf8eb27178ef8..44d14241f066be3ffa5d2658e96c9ded97106897 100644 (file)
@@ -152,6 +152,13 @@ int rte_eal_tailqs_init(void);
  */
 int rte_eal_intr_init(void);
 
+/**
+ * Close the default log stream
+ *
+ * This function is private to EAL.
+ */
+void rte_eal_log_cleanup(void);
+
 /**
  * Init alarm mechanism. This is to allow a callback be called after
  * specific time.
index b99cab25ce4833d68eb2b98a3fdcbf1f63dfbab2..fad062a2dd0e2b0b9c105fa0a3374cabc96b9667 100644 (file)
@@ -1284,6 +1284,7 @@ rte_eal_cleanup(void)
        rte_trace_save();
        eal_trace_fini();
        eal_cleanup_config(internal_conf);
+       rte_eal_log_cleanup();
        return 0;
 }
 
index c0aa1007c4dfbd10242c2c25a671f3658579a03d..5a795ac9ebe3f9f695be4d881f31979aa3c1d637 100644 (file)
@@ -37,8 +37,16 @@ console_log_write(__rte_unused void *c, const char *buf, size_t size)
        return ret;
 }
 
+static int
+console_log_close(__rte_unused void *c)
+{
+       closelog();
+       return 0;
+}
+
 static cookie_io_functions_t console_log_func = {
        .write = console_log_write,
+       .close = console_log_close,
 };
 
 /*