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

Function shutdown_plugins

lightningd/plugin.c:2126–2159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2124}
2125
2126void shutdown_plugins(struct lightningd *ld)
2127{
2128 struct plugin *p, *next;
2129
2130 /* Tell them all to shutdown; if they care. */
2131 list_for_each_safe(&ld->plugins->plugins, p, next, list) {
2132 /* Kill immediately, deletes self from list. */
2133 if (p->plugin_state != INIT_COMPLETE || !notify_plugin_shutdown(ld, p))
2134 tal_free(p);
2135 }
2136
2137 /* If anyone was interested in shutdown, give them time. */
2138 if (!list_empty(&ld->plugins->plugins)) {
2139 struct timers *timer;
2140 struct timer *expired;
2141
2142 /* 30 seconds should do it, use a clean timers struct */
2143 timer = tal(NULL, struct timers);
2144 timers_init(timer, time_mono());
2145 new_reltimer(timer, timer, time_from_sec(30), NULL, NULL);
2146
2147 void *ret = io_loop(timer, &expired);
2148 assert(ret == NULL || ret == destroy_plugin);
2149
2150 /* Report and free remaining plugins. */
2151 while (!list_empty(&ld->plugins->plugins)) {
2152 p = list_pop(&ld->plugins->plugins, struct plugin, list);
2153 log_debug(ld->log,
2154 "%s: failed to self-terminate in time, killing.",
2155 p->shortname);
2156 tal_free(p);
2157 }
2158 }
2159}

Callers 1

mainFunction · 0.70

Calls 6

notify_plugin_shutdownFunction · 0.85
tal_freeFunction · 0.85
timers_initFunction · 0.85
time_monoFunction · 0.85
time_from_secFunction · 0.85
io_loopFunction · 0.85

Tested by

no test coverage detected