From 9bec4525617774f2b8a92d9e6c4fe1bbf30a435a Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Thu, 8 Nov 2018 13:24:10 -0700 Subject: [PATCH] rpc: add function to get the current RPC state Change-Id: I74e08a4ce5d3073933721011dc5fb8a92a46c184 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/432490 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- include/spdk/rpc.h | 6 ++++++ lib/rpc/rpc.c | 6 ++++++ test/unit/lib/event/app.c/app_ut.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/spdk/rpc.h b/include/spdk/rpc.h index ab1fa61bd4..f012910b47 100644 --- a/include/spdk/rpc.h +++ b/include/spdk/rpc.h @@ -98,6 +98,12 @@ static void __attribute__((constructor)) rpc_register_##func(void) \ */ void spdk_rpc_set_state(uint32_t state_mask); +/** + * Get the current state of the RPC server. + * + * \return The current state of the RPC server. + */ +uint32_t spdk_rpc_get_state(void); #ifdef __cplusplus } diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index 985d40f46c..2b1dbd824e 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -66,6 +66,12 @@ spdk_rpc_set_state(uint32_t state) g_rpc_state = state; } +uint32_t +spdk_rpc_get_state(void) +{ + return g_rpc_state; +} + static void spdk_jsonrpc_handler(struct spdk_jsonrpc_request *request, const struct spdk_json_val *method, diff --git a/test/unit/lib/event/app.c/app_ut.c b/test/unit/lib/event/app.c/app_ut.c index 7d549261a0..8af04b7d59 100644 --- a/test/unit/lib/event/app.c/app_ut.c +++ b/test/unit/lib/event/app.c/app_ut.c @@ -59,7 +59,7 @@ DEFINE_STUB(spdk_env_get_core_count, uint32_t, (void), 1); DEFINE_STUB_V(spdk_rpc_register_method, (const char *method, spdk_rpc_method_handler func, uint32_t state_mask)); DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state)); - +DEFINE_STUB(spdk_rpc_get_state, uint32_t, (void), SPDK_RPC_RUNTIME); static void unittest_usage(void)