Commit 3266d7db authored by Jim Harris's avatar Jim Harris
Browse files

app: add spdk_app_start_shutdown()



This enables using SPDK within a larger process that
is SPDK-centric.  In this case the process may start
SPDK and then wish to stop it explicitly (without a
signal).

While here, remove an incorrect comment - DPDK mempools
can be used from non-DPDK threads.  Also set the
g_shutdown_event to NULL after it is called.  After the
event executes, the event is freed and is no longer valid.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ie4f07bee7d05fae683c72f6680cb3bcce2d4a119
parent ca998b32
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -167,6 +167,13 @@ int spdk_app_fini(void);
*/
int spdk_app_start(spdk_event_fn start_fn, void *arg1, void *arg2);

/**
 * \brief Start shutting down the framework.  Typically this function is not called directly, and
 * the shutdown process is started implicitly by a process signal.  But in applications that are
 * using SPDK for a subset of its process threads, this function can be called in lieu of a signal.
 */
void spdk_app_start_shutdown(void);

/**
 * \brief Stop the framework. This does not wait for all threads to exit. Instead, it kicks off
 * the shutdown process and returns. Once the shutdown process is complete, \ref spdk_app_start will return.
+9 −8
Original line number Diff line number Diff line
@@ -189,20 +189,21 @@ spdk_get_log_facility(struct spdk_conf *config)
	return logfacility;
}

static void
__shutdown_signal(int signo)
void
spdk_app_start_shutdown(void)
{
	/*
	 * Call pre-allocated shutdown event.  Note that it is not
	 *  safe to allocate the event within the signal handlers
	 *  context, since that context is not a DPDK thread so
	 *  buffer allocation is not permitted.
	 */
	if (g_shutdown_event != NULL) {
		spdk_event_call(g_shutdown_event);
		g_shutdown_event = NULL;
	}
}

static void
__shutdown_signal(int signo)
{
	spdk_app_start_shutdown();
}

static void
__shutdown_event_cb(spdk_event_t event)
{