diff --git a/include/spdk/event.h b/include/spdk/event.h index 3e712ed3d..dfc3fcd6a 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -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. diff --git a/lib/event/app.c b/lib/event/app.c index 35976e6b5..5c812bde9 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -189,18 +189,19 @@ spdk_get_log_facility(struct spdk_conf *config) return logfacility; } +void +spdk_app_start_shutdown(void) +{ + if (g_shutdown_event != NULL) { + spdk_event_call(g_shutdown_event); + g_shutdown_event = NULL; + } +} + static void __shutdown_signal(int signo) { - /* - * 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); - } + spdk_app_start_shutdown(); } static void