aboutsummaryrefslogtreecommitdiff
path: root/lib/jsonrpc.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-12-01 16:32:03 -0800
committerBen Pfaff <blp@nicira.com>2009-12-02 11:19:08 -0800
commit20bed8be2508ca7275b1167077f1aedfbcaa13fd (patch)
tree81ef4aafea1028ad3a1cc9aec7cf881875eae430 /lib/jsonrpc.c
parentdcbb691b0046f0d4421afbe8901d85c186929f7e (diff)
jsonrpc: Make it easy to get a new JSON-RPC request's id.
Diffstat (limited to 'lib/jsonrpc.c')
-rw-r--r--lib/jsonrpc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 817a35f1..bd019f73 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -402,10 +402,14 @@ jsonrpc_create_id(void)
}
struct jsonrpc_msg *
-jsonrpc_create_request(const char *method, struct json *params)
+jsonrpc_create_request(const char *method, struct json *params,
+ struct json **idp)
{
- return jsonrpc_create(JSONRPC_REQUEST, method, params, NULL, NULL,
- jsonrpc_create_id());
+ struct json *id = jsonrpc_create_id();
+ if (idp) {
+ *idp = json_clone(id);
+ }
+ return jsonrpc_create(JSONRPC_REQUEST, method, params, NULL, NULL, id);
}
struct jsonrpc_msg *
@@ -722,7 +726,7 @@ jsonrpc_session_run(struct jsonrpc_session *s)
struct jsonrpc_msg *request;
params = json_array_create_empty();
- request = jsonrpc_create_request("echo", params);
+ request = jsonrpc_create_request("echo", params, NULL);
json_destroy(request->id);
request->id = json_string_create("echo");
jsonrpc_send(s->rpc, request);