[01/14] eal: log: close on cleanup
Checks
Commit Message
When application calls rte_eal_cleanup on shutdown,
the DPDK log should be closed and cleaned up.
Fixes: af75078fece3 ("first public release")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_eal/common/eal_common_log.c | 12 ++++++++++++
lib/librte_eal/common/eal_private.h | 13 +++++++++++++
lib/librte_eal/linux/eal/eal.c | 1 +
lib/librte_eal/linux/eal/eal_log.c | 14 ++++++++++++++
4 files changed, 40 insertions(+)
@@ -463,3 +463,15 @@ eal_log_set_default(FILE *default_log)
"Debug dataplane logs available - lower performance\n");
#endif
}
+
+/*
+ * Called by envrionment-specific cleanup function.
+ */
+void
+eal_log_cleanup(void)
+{
+ if (default_log_stream) {
+ fclose(default_log_stream);
+ default_log_stream = NULL;
+ }
+}
@@ -90,6 +90,12 @@ int rte_eal_memzone_init(void);
*/
void eal_log_set_default(FILE *default_log);
+/**
+ * Common log cleanup function (private to eal).
+ * Closes the default log stream. Called from rte_eal_cleanup().
+ */
+void eal_log_cleanup(void);
+
/**
* Fill configuration with number of physical and logical processors
*
@@ -151,6 +157,13 @@ int rte_eal_timer_init(void);
*/
int rte_eal_log_init(const char *id, int facility);
+/**
+ * Close the default log stream
+ *
+ * This function is private to EAL.
+ */
+void rte_eal_log_cleanup(void);
+
/**
* Save the log regexp for later
*/
@@ -1327,6 +1327,7 @@ rte_eal_cleanup(void)
rte_service_finalize();
rte_mp_channel_cleanup();
eal_cleanup_config(&internal_config);
+ rte_eal_log_cleanup();
return 0;
}
@@ -37,8 +37,16 @@ console_log_write(__attribute__((unused)) void *c, const char *buf, size_t size)
return ret;
}
+static int
+console_log_close(__attribute__((unused)) void *c)
+{
+ closelog();
+ return 0;
+}
+
static cookie_io_functions_t console_log_func = {
.write = console_log_write,
+ .close = console_log_close,
};
/*
@@ -60,3 +68,9 @@ rte_eal_log_init(const char *id, int facility)
return 0;
}
+
+void
+rte_eal_log_cleanup(void)
+{
+ eal_log_cleanup();
+}