From 1d2700d4c113e258541d2d84a4d7458019b4df75 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 17 Nov 2022 06:21:18 +0000 Subject: [PATCH] event: check that all non-app threads have exited at shutdown For now, just print a loud warning when this case is violated. We will add a hard assertion and cause the app to exit with error status in a later release. Signed-off-by: Jim Harris Change-Id: Ic9226f76a4729820f13a2728bea977b6a54f48ee Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15513 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk --- lib/event/reactor.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index a03263274..90707b3dc 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -964,8 +964,18 @@ reactor_run(void *arg) TAILQ_FOREACH(lw_thread, &reactor->threads, link) { thread = spdk_thread_get_from_ctx(lw_thread); - spdk_set_thread(thread); - spdk_thread_exit(thread); + /* All threads should have already had spdk_thread_exit() called on them, except + * for the app thread. + */ + if (spdk_thread_is_running(thread)) { + if (thread != spdk_thread_get_app_thread()) { + SPDK_ERRLOG("spdk_thread_exit() was not called on thread '%s'\n", + spdk_thread_get_name(thread)); + SPDK_ERRLOG("This will result in a non-zero exit code in a future release.\n"); + } + spdk_set_thread(thread); + spdk_thread_exit(thread); + } } while (!TAILQ_EMPTY(&reactor->threads)) {