| 561 | WARN_UNUSED_RESULT; |
| 562 | |
| 563 | static const char *plugin_response_handle(struct plugin *plugin, |
| 564 | const jsmntok_t *toks, |
| 565 | const jsmntok_t *idtok) |
| 566 | { |
| 567 | struct plugin_destroyed *pd; |
| 568 | struct jsonrpc_request *request; |
| 569 | |
| 570 | request = strmap_getn(&plugin->plugins->pending_requests, |
| 571 | plugin->buffer + idtok->start, |
| 572 | idtok->end - idtok->start); |
| 573 | if (!request) { |
| 574 | return tal_fmt( |
| 575 | plugin, |
| 576 | "Received a JSON-RPC response for non-existent request"); |
| 577 | } |
| 578 | |
| 579 | /* We expect the request->cb to copy if needed */ |
| 580 | pd = plugin_detect_destruction(plugin); |
| 581 | request->response_cb(plugin->buffer, toks, idtok, request->response_cb_arg); |
| 582 | |
| 583 | /* Note that in the case of 'plugin stop' this can free request (since |
| 584 | * plugin is parent), so detect that case */ |
| 585 | if (!was_plugin_destroyed(pd)) |
| 586 | tal_free(request); |
| 587 | |
| 588 | return NULL; |
| 589 | } |
| 590 | |
| 591 | /** |
| 592 | * Try to parse a complete message from the plugin's buffer. |
no test coverage detected