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