| 142 | } |
| 143 | |
| 144 | static struct command_result * |
| 145 | plugin_dynamic_stop(struct command *cmd, const char *plugin_name) |
| 146 | { |
| 147 | struct plugin *p; |
| 148 | |
| 149 | list_for_each(&cmd->ld->plugins->plugins, p, list) { |
| 150 | if (plugin_paths_match(p->cmd, plugin_name)) { |
| 151 | if (!p->dynamic) |
| 152 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 153 | "%s cannot be managed when " |
| 154 | "lightningd is up", |
| 155 | plugin_name); |
| 156 | |
| 157 | /* If it's interested in clean shutdown, tell it. */ |
| 158 | if (notify_plugin_shutdown(cmd->ld, p)) { |
| 159 | struct plugin_stop_timeout *pst; |
| 160 | |
| 161 | /* Kill in 30 seconds if it doesn't exit. */ |
| 162 | pst = tal(p, struct plugin_stop_timeout); |
| 163 | pst->p = p; |
| 164 | pst->cmd = cmd; |
| 165 | notleak(new_reltimer(cmd->ld->timers, pst, |
| 166 | time_from_sec(30), |
| 167 | plugin_stop_timeout, |
| 168 | pst)); |
| 169 | |
| 170 | tal_add_destructor2(p, plugin_stopped, cmd); |
| 171 | return command_still_pending(cmd); |
| 172 | } |
| 173 | return plugin_stop(cmd, p, true); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 178 | "Could not find plugin %s", plugin_name); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Look for additions in the default plugin directory. |
no test coverage detected