aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/json_rpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/json_rpc.c')
-rw-r--r--src/json_rpc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/json_rpc.c b/src/json_rpc.c
index 7630f64..31794ec 100644
--- a/src/json_rpc.c
+++ b/src/json_rpc.c
@@ -11,6 +11,7 @@
#include <json-c/json_object.h>
+#include <stdatomic.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -52,6 +53,13 @@ static int jsonrpc_set_version(struct json_object *obj)
return json_set_string_const_key(obj, jsonrpc_key_version, jsonrpc_value_version);
}
+static _Atomic int jsonrpc_id_counter = 1;
+
+int jsonrpc_generate_request_id(void)
+{
+ return jsonrpc_id_counter++;
+}
+
static int jsonrpc_check_id_type(struct json_object *id)
{
if (!json_object_is_type(id, json_type_string) && !json_object_is_type(id, json_type_int)) {