event: No longer require event in spdk_subsystem_fini

Just use a function pointer and a context.

Change-Id: I2d41ed2572d892f3328aadf7f22d8696816bf4d1
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446995
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2019-03-04 13:16:56 -07:00 committed by Changpeng Liu
parent f90c3be49e
commit 4d6a89044f
5 changed files with 19 additions and 22 deletions

View File

@ -51,7 +51,7 @@ int spdk_reactors_init(void);
void spdk_reactors_fini(void);
void spdk_reactors_start(void);
void spdk_reactors_stop(void *arg1, void *arg2);
void spdk_reactors_stop(void *arg1);
struct spdk_subsystem {
const char *name;
@ -88,7 +88,7 @@ void spdk_add_subsystem(struct spdk_subsystem *subsystem);
void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);
void spdk_subsystem_init(spdk_msg_fn cb_fn, void *cb_arg);
void spdk_subsystem_fini(struct spdk_event *app_finish_event);
void spdk_subsystem_fini(spdk_msg_fn cb_fn, void *cb_arg);
void spdk_subsystem_init_next(int rc);
void spdk_subsystem_fini_next(void);
void spdk_subsystem_config(FILE *fp);

View File

@ -703,12 +703,8 @@ spdk_app_fini(void)
static void
_spdk_app_stop(void *arg1, void *arg2)
{
struct spdk_event *app_stop_event;
spdk_rpc_finish();
app_stop_event = spdk_event_allocate(spdk_env_get_current_core(), spdk_reactors_stop, NULL, NULL);
spdk_subsystem_fini(app_stop_event);
spdk_subsystem_fini(spdk_reactors_stop, NULL);
}
void

View File

@ -338,7 +338,7 @@ spdk_reactors_start(void)
}
void
spdk_reactors_stop(void *arg1, void *arg2)
spdk_reactors_stop(void *arg1)
{
g_reactor_state = SPDK_REACTOR_STATE_EXITING;
}

View File

@ -46,8 +46,9 @@ static bool g_subsystems_initialized = false;
static bool g_subsystems_init_interrupted = false;
static spdk_msg_fn g_app_start_fn = NULL;
static void *g_app_start_arg = NULL;
static struct spdk_event *g_app_stop_event;
static uint32_t g_fini_core;
static spdk_msg_fn g_app_stop_fn = NULL;
static void *g_app_stop_arg = NULL;
static struct spdk_thread *g_fini_thread = NULL;
void
spdk_add_subsystem(struct spdk_subsystem *subsystem)
@ -187,9 +188,9 @@ spdk_subsystem_init(spdk_msg_fn cb_fn, void *cb_arg)
}
static void
_spdk_subsystem_fini_next(void *arg1, void *arg2)
_spdk_subsystem_fini_next(void *arg1)
{
assert(g_fini_core == spdk_env_get_current_core());
assert(g_fini_thread == spdk_get_thread());
if (!g_next_subsystem) {
/* If the initialized flag is false, then we've failed to initialize
@ -214,28 +215,27 @@ _spdk_subsystem_fini_next(void *arg1, void *arg2)
g_next_subsystem = TAILQ_PREV(g_next_subsystem, spdk_subsystem_list, tailq);
}
spdk_event_call(g_app_stop_event);
g_app_stop_fn(g_app_stop_arg);
return;
}
void
spdk_subsystem_fini_next(void)
{
if (g_fini_core != spdk_env_get_current_core()) {
struct spdk_event *event;
event = spdk_event_allocate(g_fini_core, _spdk_subsystem_fini_next, NULL, NULL);
spdk_event_call(event);
if (g_fini_thread != spdk_get_thread()) {
spdk_thread_send_msg(g_fini_thread, _spdk_subsystem_fini_next, NULL);
} else {
_spdk_subsystem_fini_next(NULL, NULL);
_spdk_subsystem_fini_next(NULL);
}
}
void
spdk_subsystem_fini(struct spdk_event *app_stop_event)
spdk_subsystem_fini(spdk_msg_fn cb_fn, void *cb_arg)
{
g_app_stop_event = app_stop_event;
g_fini_core = spdk_env_get_current_core();
g_app_stop_fn = cb_fn;
g_app_stop_arg = cb_arg;
g_fini_thread = spdk_get_thread();
spdk_subsystem_fini_next();
}

View File

@ -37,6 +37,7 @@
#include "unit/lib/json_mock.c"
#include "event/subsystem.c"
#include "common/lib/test_env.c"
static struct spdk_subsystem g_ut_subsystems[8];
static struct spdk_subsystem_depend g_ut_subsystem_deps[8];