}
if (msg->params) {
ds_put_cstr(&s, ", params=");
- ds_put_and_free_cstr(&s, json_to_string(msg->params, 0));
+ json_to_ds(msg->params, 0, &s);
}
if (msg->result) {
ds_put_cstr(&s, ", result=");
- ds_put_and_free_cstr(&s, json_to_string(msg->result, 0));
+ json_to_ds(msg->result, 0, &s);
}
if (msg->error) {
ds_put_cstr(&s, ", error=");
- ds_put_and_free_cstr(&s, json_to_string(msg->error, 0));
+ json_to_ds(msg->error, 0, &s);
}
if (msg->id) {
ds_put_cstr(&s, ", id=");
- ds_put_and_free_cstr(&s, json_to_string(msg->id, 0));
+ json_to_ds(msg->id, 0, &s);
}
VLOG_DBG("%s: %s %s%s", rpc->name, title,
jsonrpc_msg_type_to_string(msg->type), ds_cstr(&s));
}
}
+/* Always takes ownership of 'msg', regardless of success. */
int
jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
{
}
}
+/* Always takes ownership of 'msg', regardless of success. */
int
jsonrpc_send_block(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
{
}
}
+/* Always takes ownership of 'request', regardless of success. */
int
jsonrpc_transact_block(struct jsonrpc *rpc, struct jsonrpc_msg *request,
struct jsonrpc_msg **replyp)
return reconnect_get_name(s->reconnect);
}
+/* Always takes ownership of 'msg', regardless of success. */
int
jsonrpc_session_send(struct jsonrpc_session *s, struct jsonrpc_msg *msg)
{
- return s->rpc ? jsonrpc_send(s->rpc, msg) : ENOTCONN;
+ if (s->rpc) {
+ return jsonrpc_send(s->rpc, msg);
+ } else {
+ jsonrpc_msg_destroy(msg);
+ return ENOTCONN;
+ }
}
struct jsonrpc_msg *