| 720 | } |
| 721 | |
| 722 | static const char *read_one_json_sync(struct plugin *p, const jsmntok_t **toks) |
| 723 | { |
| 724 | for (;;) { |
| 725 | const char *buf, *error; |
| 726 | |
| 727 | error = jsonrpc_io_parse(tmpctx, p->sync_io, toks, &buf); |
| 728 | if (error) |
| 729 | plugin_err(p, "Parsing sync lightningd: %s", error); |
| 730 | if (*toks) |
| 731 | return buf; |
| 732 | |
| 733 | /* lightningd goes away, we go away. */ |
| 734 | if (!jsonrpc_sync_read(p->sync_io, p->sync_fd)) { |
| 735 | if (errno == 0) |
| 736 | exit(0); |
| 737 | else |
| 738 | plugin_err(p, "Reading sync lightningd: %s", |
| 739 | strerror(errno)); |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | /* Reads rpc reply and returns result tokens */ |
| 745 | static const jsmntok_t *read_sync_rpc_reply(const tal_t *ctx, |
no test coverage detected