| 1386 | |
| 1387 | |
| 1388 | static struct io_plan *rpc_conn_read_response(struct io_conn *conn, |
| 1389 | struct plugin *plugin) |
| 1390 | { |
| 1391 | const tal_t *working_ctx = tal(NULL, char); |
| 1392 | |
| 1393 | /* Gather an parse any new bytes */ |
| 1394 | for (;;) { |
| 1395 | const jsmntok_t *toks; |
| 1396 | const char *buf; |
| 1397 | const char *err; |
| 1398 | |
| 1399 | err = jsonrpc_io_parse(tmpctx, |
| 1400 | plugin->jsonrpc_in, |
| 1401 | &toks, &buf); |
| 1402 | if (err) |
| 1403 | plugin_err(plugin, "%s", err); |
| 1404 | |
| 1405 | if (!toks) |
| 1406 | break; |
| 1407 | |
| 1408 | handle_rpc_reply(working_ctx, plugin, buf, toks); |
| 1409 | jsonrpc_io_parse_done(plugin->jsonrpc_in); |
| 1410 | } |
| 1411 | |
| 1412 | /* Explicitly free any expired requests now; xpay uses this to |
| 1413 | * fire more commands! */ |
| 1414 | tal_free(working_ctx); |
| 1415 | |
| 1416 | /* Read more */ |
| 1417 | return jsonrpc_io_read(conn, plugin->jsonrpc_in, |
| 1418 | rpc_conn_read_response, |
| 1419 | plugin); |
| 1420 | } |
| 1421 | |
| 1422 | static struct io_plan *rpc_conn_write_request(struct io_conn *conn, |
| 1423 | struct plugin *plugin); |
no test coverage detected