MCPcopy Create free account
hub / github.com/ElementsProject/lightning / plugin_dynamic_stop

Function plugin_dynamic_stop

lightningd/plugin_control.c:146–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

json_plugin_controlFunction · 0.85

Calls 6

plugin_paths_matchFunction · 0.85
notify_plugin_shutdownFunction · 0.85
time_from_secFunction · 0.85
plugin_stopFunction · 0.85
command_failFunction · 0.70
command_still_pendingFunction · 0.70

Tested by

no test coverage detected