Commit 719343c9 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I81a57407acb772cd869819f2fac6665f61935369
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1642


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e7ead00b
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -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)
{