RPC: update the error message for current RPC state

This is to fix below issue:
https://github.com/spdk/spdk/issues/1516

Change-Id: Ibd7b4692b3d94fb7131aa0763d7fb7f6298d4101
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3565
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
GangCao 2020-07-29 16:49:31 -04:00 committed by Tomasz Zawadzki
parent f6fcba38e8
commit 51e8c2362b

View File

@ -127,10 +127,21 @@ jsonrpc_handler(struct spdk_jsonrpc_request *request,
if ((m->state_mask & g_rpc_state) == g_rpc_state) {
m->func(request, params);
} else {
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_STATE,
"Method is allowed in any state in the mask (%"PRIx32"),"
" but current state is (%"PRIx32")",
m->state_mask, g_rpc_state);
if (g_rpc_state == SPDK_RPC_STARTUP) {
spdk_jsonrpc_send_error_response_fmt(request,
SPDK_JSONRPC_ERROR_INVALID_STATE,
"Method may only be called after "
"framework is initialized "
"using framework_start_init RPC.");
} else {
spdk_jsonrpc_send_error_response_fmt(request,
SPDK_JSONRPC_ERROR_INVALID_STATE,
"Method may only be called before "
"framework is initialized. "
"Use --wait-for-rpc command line "
"parameter and then issue this RPC "
"before the framework_start_init RPC.");
}
}
}