From 29093c7f01c1bcb3ef43252ec800622a172736fa Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 18 Jun 2019 07:31:26 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458351 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker --- lib/event/app.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/event/app.c b/lib/event/app.c index daee8a1d1f..f670aa35dd 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -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) {