lib/thread: Change spdk_thread_exit() to nest wrapper function and function body

Change spdk_thread_exit() to nest a wrapper function, spdk_thread_exit()
and a static function made of function body. Include the check if the
state is running into the wrapper function.

These will make the following patches easier.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I81a57407acb772cd869819f2fac6665f61935369
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1642
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-04-04 11:32:58 +09:00 committed by Tomasz Zawadzki
parent e7ead00b53
commit 719343c94a

View File

@ -314,22 +314,12 @@ spdk_set_thread(struct spdk_thread *thread)
tls_thread = thread;
}
int
spdk_thread_exit(struct spdk_thread *thread)
static int
_spdk_thread_exit(struct spdk_thread *thread)
{
struct spdk_poller *poller;
struct spdk_io_channel *ch;
SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Exit thread %s\n", thread->name);
assert(tls_thread == thread);
if (thread->exit) {
SPDK_INFOLOG(SPDK_LOG_THREAD, "thread %s is already marked as exited\n",
thread->name);
return 0;
}
TAILQ_FOREACH(poller, &thread->active_pollers, tailq) {
if (poller->state != SPDK_POLLER_STATE_UNREGISTERED) {
SPDK_ERRLOG("thread %s still has active poller %s\n",
@ -364,6 +354,23 @@ spdk_thread_exit(struct spdk_thread *thread)
return 0;
}
int
spdk_thread_exit(struct spdk_thread *thread)
{
SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Exit thread %s\n", thread->name);
assert(tls_thread == thread);
if (thread->exit) {
SPDK_INFOLOG(SPDK_LOG_THREAD,
"thread %s is already marked as exited\n",
thread->name);
return 0;
}
return _spdk_thread_exit(thread);
}
bool
spdk_thread_is_exited(struct spdk_thread *thread)
{