diff --git a/lib/init/subsystem.c b/lib/init/subsystem.c index 6e3b2318f..f850e6d7a 100644 --- a/lib/init/subsystem.c +++ b/lib/init/subsystem.c @@ -132,6 +132,8 @@ subsystem_sort(void) void spdk_subsystem_init_next(int rc) { + assert(spdk_get_thread() == spdk_thread_get_app_thread()); + /* The initialization is interrupted by the spdk_subsystem_fini, so just return */ if (g_subsystems_init_interrupted) { return; @@ -167,6 +169,8 @@ spdk_subsystem_init(spdk_subsystem_init_fn cb_fn, void *cb_arg) { struct spdk_subsystem_depend *dep; + assert(spdk_get_thread() == spdk_thread_get_app_thread()); + g_subsystem_start_fn = cb_fn; g_subsystem_start_arg = cb_arg; diff --git a/test/unit/lib/init/subsystem.c/subsystem_ut.c b/test/unit/lib/init/subsystem.c/subsystem_ut.c index 3197dc138..3b06f6a53 100644 --- a/test/unit/lib/init/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/init/subsystem.c/subsystem_ut.c @@ -208,12 +208,17 @@ main(int argc, char **argv) { CU_pSuite suite = NULL; unsigned int num_failures; + struct spdk_thread *thread; CU_set_error_action(CUEA_ABORT); CU_initialize_registry(); suite = CU_add_suite("subsystem_suite", NULL, NULL); + spdk_thread_lib_init(NULL, 0); + thread = spdk_thread_create(NULL, NULL); + spdk_set_thread(thread); + CU_ADD_TEST(suite, subsystem_sort_test_depends_on_single); CU_ADD_TEST(suite, subsystem_sort_test_depends_on_multiple); CU_ADD_TEST(suite, subsystem_sort_test_missing_dependency);