diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index de10103c8..df9d1e55f 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -87,6 +87,18 @@ _get_rpc_method(const struct spdk_json_val *method) return NULL; } +static struct spdk_rpc_method * +_get_rpc_method_raw(const char *method) +{ + struct spdk_json_val method_val; + + method_val.type = SPDK_JSON_VAL_STRING; + method_val.len = strlen(method); + method_val.start = (char *)method; + + return _get_rpc_method(&method_val); +} + static void spdk_jsonrpc_handler(struct spdk_jsonrpc_request *request, const struct spdk_json_val *method, @@ -224,6 +236,12 @@ spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func, uint3 { struct spdk_rpc_method *m; + m = _get_rpc_method_raw(method); + if (m != NULL) { + SPDK_ERRLOG("duplicate RPC %s registered - ignoring...\n", method); + return; + } + m = calloc(1, sizeof(struct spdk_rpc_method)); assert(m != NULL);