From 51e8c2362b21404435cb8d5a1531f5c64875e112 Mon Sep 17 00:00:00 2001 From: GangCao Date: Wed, 29 Jul 2020 16:49:31 -0400 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3565 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/rpc/rpc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index 7182f41e9..9662b887d 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -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."); + } } }