Browse Source

libplugin: ignore incoming notifications.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-experimental
Rusty Russell 4 years ago
parent
commit
572c849873
  1. 25
      plugins/libplugin.c

25
plugins/libplugin.c

@ -447,13 +447,18 @@ static const jsmntok_t *read_rpc_reply(const tal_t *ctx,
{ {
const jsmntok_t *toks; const jsmntok_t *toks;
*reqlen = read_json_from_rpc(plugin); do {
*reqlen = read_json_from_rpc(plugin);
toks = json_parse_simple(ctx,
membuf_elems(&plugin->rpc_conn->mb), *reqlen); toks = json_parse_simple(ctx,
if (!toks) membuf_elems(&plugin->rpc_conn->mb),
plugin_err(plugin, "Malformed JSON reply '%.*s'", *reqlen);
*reqlen, membuf_elems(&plugin->rpc_conn->mb)); if (!toks)
plugin_err(plugin, "Malformed JSON reply '%.*s'",
*reqlen, membuf_elems(&plugin->rpc_conn->mb));
/* FIXME: Don't simply ignore notifications here! */
} while (!json_get_member(membuf_elems(&plugin->rpc_conn->mb), toks,
"id"));
*contents = json_get_member(membuf_elems(&plugin->rpc_conn->mb), toks, "error"); *contents = json_get_member(membuf_elems(&plugin->rpc_conn->mb), toks, "error");
if (*contents) if (*contents)
@ -525,9 +530,9 @@ static void handle_rpc_reply(struct plugin *plugin, const jsmntok_t *toks)
idtok = json_get_member(plugin->rpc_buffer, toks, "id"); idtok = json_get_member(plugin->rpc_buffer, toks, "id");
if (!idtok) if (!idtok)
plugin_err(plugin, "JSON reply without id '%.*s'", /* FIXME: Don't simply ignore notifications! */
json_tok_full_len(toks), return;
json_tok_full(plugin->rpc_buffer, toks));
if (!json_to_u64(plugin->rpc_buffer, idtok, &id)) if (!json_to_u64(plugin->rpc_buffer, idtok, &id))
plugin_err(plugin, "JSON reply without numeric id '%.*s'", plugin_err(plugin, "JSON reply without numeric id '%.*s'",
json_tok_full_len(toks), json_tok_full_len(toks),

Loading…
Cancel
Save