event: Use threads for shutdown handling instead of events

Change-Id: I841ebf29ddcb46038a07d5b0b7781aac938c5869
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447116
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ben Walker 2019-03-05 14:33:52 -07:00 committed by Changpeng Liu
parent 8f3b4a3a6d
commit 9603e344ae

View File

@ -69,7 +69,6 @@ struct spdk_app {
static struct spdk_app g_spdk_app;
static spdk_msg_fn g_start_fn = NULL;
static void *g_start_arg = NULL;
static struct spdk_event *g_shutdown_event = NULL;
static struct spdk_thread *g_app_thread = NULL;
static bool g_delay_subsystem_init = false;
static bool g_shutdown_sig_received = false;
@ -221,17 +220,23 @@ spdk_app_get_running_config(char **config_str, char *name)
return 0;
}
void
spdk_app_start_shutdown(void)
static void
app_start_shutdown(void *ctx)
{
if (g_shutdown_event != NULL) {
spdk_event_call(g_shutdown_event);
g_shutdown_event = NULL;
if (g_spdk_app.shutdown_cb) {
g_spdk_app.shutdown_cb();
g_spdk_app.shutdown_cb = NULL;
} else {
spdk_app_stop(0);
}
}
void
spdk_app_start_shutdown(void)
{
spdk_thread_send_msg(g_app_thread, app_start_shutdown, NULL);
}
static void
__shutdown_signal(int signo)
{
@ -241,12 +246,6 @@ __shutdown_signal(int signo)
}
}
static void
__shutdown_event_cb(void *arg1, void *arg2)
{
g_spdk_app.shutdown_cb();
}
static int
spdk_app_opts_validate(const char *app_opts)
{
@ -295,13 +294,6 @@ spdk_app_setup_signal_handlers(struct spdk_app_opts *opts)
sigset_t sigmask;
int rc;
/* Set up custom shutdown handling if the user requested it. */
if (opts->shutdown_cb != NULL) {
g_shutdown_event = spdk_event_allocate(spdk_env_get_current_core(),
__shutdown_event_cb,
NULL, NULL);
}
sigemptyset(&sigmask);
memset(&sigact, 0, sizeof(sigact));
sigemptyset(&sigact.sa_mask);