* Called when trying to start a plugin through RPC, it starts the plugin and * will give a result 60 seconds later at the most (once init completes). */
| 62 | * will give a result 60 seconds later at the most (once init completes). |
| 63 | */ |
| 64 | static struct command_result * |
| 65 | plugin_dynamic_start(struct plugin_command *pcmd, const char *plugin_path, |
| 66 | const char *buffer, const jsmntok_t *params) |
| 67 | { |
| 68 | struct plugin *p = plugin_register(pcmd->cmd->ld->plugins, plugin_path, pcmd, false, buffer, params); |
| 69 | const char *err; |
| 70 | |
| 71 | if (!p) |
| 72 | return command_fail(pcmd->cmd, JSONRPC2_INVALID_PARAMS, |
| 73 | "%s: %s", plugin_path, |
| 74 | errno ? strerror(errno) : "already registered"); |
| 75 | |
| 76 | err = plugin_send_getmanifest(p, pcmd->cmd->id); |
| 77 | if (err) { |
| 78 | /* Free plugin with cmd (it owns buffer and params!) */ |
| 79 | tal_steal(pcmd->cmd, p); |
| 80 | return command_fail(pcmd->cmd, PLUGIN_ERROR, |
| 81 | "%s: %s", |
| 82 | plugin_path, err); |
| 83 | } |
| 84 | |
| 85 | /* This will come back via plugin_cmd_killed or plugin_cmd_succeeded */ |
| 86 | return command_still_pending(pcmd->cmd); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Called when trying to start a plugin directory through RPC, it registers |
no test coverage detected