From f7ddfcf743b709455d2176e42618d67911f585bc Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 8 Oct 2019 09:11:24 +0000 Subject: [PATCH] reactor: allow spdk_reactors_fini() to be called without prior init spdk_reactors_fini() is unconditionally called in spdk_app_fini() at the end of every application and it currently throws a ton of warning messages if the reactors weren't initialized yet [1]. Let's silence those warnings. [1] $ spdk_tgt -c invalid.conf [...] *WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL! *WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL! *WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL! *WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL! *WARNING*: Called spdk_reactor_get() while the g_reactors array was NULL! (Apparently SPDK_ENV_FOREACH_CORE iterates through 128 cores if the dpdk env framework wasn't initialized. SPDK calls spdk_reactor_get() on each core and that's what generates the warnings) Signed-off-by: Darek Stojaczyk Change-Id: Ic3a2355ef6d2e0d0e1cc125ba21cc6a802b355bc Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470736 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/event/reactor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index b3cb09dff..6bd0e11bb 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -54,7 +54,7 @@ #define SPDK_EVENT_BATCH_SIZE 8 enum spdk_reactor_state { - SPDK_REACTOR_STATE_INVALID = 0, + SPDK_REACTOR_STATE_UNINITIALIZED = 0, SPDK_REACTOR_STATE_INITIALIZED = 1, SPDK_REACTOR_STATE_RUNNING = 2, SPDK_REACTOR_STATE_EXITING = 3, @@ -85,7 +85,7 @@ struct spdk_reactor { static struct spdk_reactor *g_reactors; static struct spdk_cpuset *g_reactor_core_mask; -static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_INVALID; +static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_UNINITIALIZED; static bool g_framework_monitor_context_switch_enabled = true; @@ -173,6 +173,10 @@ spdk_reactors_fini(void) uint32_t i; struct spdk_reactor *reactor; + if (g_reactor_state == SPDK_REACTOR_STATE_UNINITIALIZED) { + return; + } + spdk_thread_lib_fini(); SPDK_ENV_FOREACH_CORE(i) {