[dpdk-dev] [PATCH 01/14] eal: log: close on cleanup
Stephen Hemminger
stephen at networkplumber.org
Sat Jan 4 02:33:28 CET 2020
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 at 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(+)
diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
index c0efd5214fa9..64d6e20947ed 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -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;
+ }
+}
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 8a9d493f0c54..fdd942d71a36 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -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
*/
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index c4233ec3c8ac..a3381fd01a23 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -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;
}
diff --git a/lib/librte_eal/linux/eal/eal_log.c b/lib/librte_eal/linux/eal/eal_log.c
index 9d02dddbed33..e1adbc91637a 100644
--- a/lib/librte_eal/linux/eal/eal_log.c
+++ b/lib/librte_eal/linux/eal/eal_log.c
@@ -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();
+}
--
2.20.1
More information about the dev
mailing list