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