Skip to content

Commit

Permalink
app: add spdk_app_start_shutdown()
Browse files Browse the repository at this point in the history
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: Jim Harris <james.r.harris@intel.com>
Change-Id: Ie4f07bee7d05fae683c72f6680cb3bcce2d4a119
  • Loading branch information
jimharris committed Nov 7, 2016
1 parent ca998b3 commit 3266d7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions include/spdk/event.h
Expand Up @@ -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.
Expand Down
17 changes: 9 additions & 8 deletions lib/event/app.c
Expand Up @@ -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)
{
Expand Down

0 comments on commit 3266d7d

Please sign in to comment.