event/app: don't call start_fn twice when json config is used

When JSON config was used, app layer was calling the
app start callback twice - once from internally-sent
"start_subsystem_init" RPC, and once from the app layer
itself.

In case of JSON configs, the callback from within the
RPC was actually called prematurely, as the real RPC
server was still starting in the background at that
point. We still need to start the app from that RPC in
case of `--wait-for-listen` option, but for JSON configs
it doesn't make sense. Just ignore it now and rely on
json config load completion callback to start the app.

Fixes #816

Change-Id: Ib54d624f3167137216c910b2d947bbd1dc5023b1
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458351
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Darek Stojaczyk 2019-06-18 07:31:26 +02:00
parent a7d9fc4a4d
commit 29093c7f01

View File

@ -340,8 +340,6 @@ spdk_app_setup_signal_handlers(struct spdk_app_opts *opts)
static void
spdk_app_start_application(void)
{
spdk_rpc_set_state(SPDK_RPC_RUNTIME);
assert(spdk_get_thread() == g_app_thread);
g_start_fn(g_start_arg);
@ -352,6 +350,7 @@ spdk_app_start_rpc(void *arg1)
{
spdk_rpc_initialize(g_spdk_app.rpc_addr);
if (!g_delay_subsystem_init) {
spdk_rpc_set_state(SPDK_RPC_RUNTIME);
spdk_app_start_application();
}
}
@ -1061,7 +1060,15 @@ spdk_rpc_start_subsystem_init_cpl(void *arg1)
assert(spdk_get_thread() == g_app_thread);
spdk_app_start_application();
spdk_rpc_set_state(SPDK_RPC_RUNTIME);
/* If we're loading JSON config file, we're still operating on a fake,
* temporary RPC server. We'll have to defer calling the app start callback
* until this temporary server is shut down and a real one - listening on
* the proper socket - is started.
*/
if (g_spdk_app.json_config_file == NULL) {
spdk_app_start_application();
}
w = spdk_jsonrpc_begin_result(request);
if (w == NULL) {