diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 1d7266635..eb2e2db84 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -392,10 +392,8 @@ _spdk_reactor_run(void *arg) assert(reactor->thread_count > 0); reactor->thread_count--; spdk_set_thread(thread); - if (!spdk_thread_is_exited(thread)) { - rc = spdk_thread_exit(thread); - assert(rc == 0); - } + rc = spdk_thread_exit(thread); + assert(rc == 0); spdk_thread_destroy(thread); } diff --git a/lib/thread/thread.c b/lib/thread/thread.c index c63d25a19..1a9c98544 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -325,9 +325,9 @@ spdk_thread_exit(struct spdk_thread *thread) assert(tls_thread == thread); if (thread->exit) { - SPDK_ERRLOG("thread %s is already marked as exited\n", - thread->name); - return -EINVAL; + SPDK_INFOLOG(SPDK_LOG_THREAD, "thread %s is already marked as exited\n", + thread->name); + return 0; } TAILQ_FOREACH(poller, &thread->active_pollers, tailq) { diff --git a/test/common/lib/ut_multithread.c b/test/common/lib/ut_multithread.c index 0a01e03b9..973995b05 100644 --- a/test/common/lib/ut_multithread.c +++ b/test/common/lib/ut_multithread.c @@ -107,10 +107,8 @@ free_threads(void) for (i = 0; i < g_ut_num_threads; i++) { set_thread(i); - if (!spdk_thread_is_exited(g_ut_threads[i].thread)) { - rc = spdk_thread_exit(g_ut_threads[i].thread); - assert(rc == 0); - } + rc = spdk_thread_exit(g_ut_threads[i].thread); + assert(rc == 0); spdk_thread_destroy(g_ut_threads[i].thread); g_ut_threads[i].thread = NULL; } diff --git a/test/unit/lib/thread/thread.c/thread_ut.c b/test/unit/lib/thread/thread.c/thread_ut.c index e2fa62bfd..53beeb910 100644 --- a/test/unit/lib/thread/thread.c/thread_ut.c +++ b/test/unit/lib/thread/thread.c/thread_ut.c @@ -852,13 +852,13 @@ thread_exit(void) spdk_io_device_unregister(&g_device1, NULL); poll_threads(); - /* Test call spdk_thread_exit() is only once for a single thread. */ + /* Test 2nd spdk_thread_exit() call is ignored. */ set_thread(3); thread = spdk_get_thread(); CU_ASSERT(spdk_thread_exit(thread) == 0); - CU_ASSERT(spdk_thread_exit(thread) == -EINVAL); + CU_ASSERT(spdk_thread_exit(thread) == 0); /* Test if spdk_thread_exit() fails when there is any registered poller, * and if no poller is executed after the thread is marked as exited.