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

Function shutdown_plugins

lightningd/plugin.c:2595–2631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2593}
2594
2595void shutdown_plugins(struct lightningd *ld)
2596{
2597 struct plugin *p, *next;
2598
2599 /* Tell them all to shutdown; if they care. */
2600 list_for_each_safe(&ld->plugins->plugins, p, next, list) {
2601 /* Clear all pending requests, so we don't try to answer them. */
2602 strmap_iterate(&p->pending_requests, release_request, p);
2603 strmap_clear(&p->pending_requests);
2604 /* Kill immediately, deletes self from list. */
2605 if (p->plugin_state != INIT_COMPLETE || !notify_plugin_shutdown(ld, p))
2606 tal_free(p);
2607 }
2608
2609 /* If anyone was interested in shutdown, give them time. */
2610 if (!list_empty(&ld->plugins->plugins)) {
2611 struct timers *timer;
2612 struct timer *expired;
2613
2614 /* 30 seconds should do it, use a clean timers struct */
2615 timer = tal(NULL, struct timers);
2616 timers_init(timer, time_mono());
2617 new_reltimer(timer, timer, time_from_sec(30), NULL, NULL);
2618
2619 void *ret = io_loop(timer, &expired);
2620 assert(ret == NULL || ret == destroy_plugin);
2621
2622 /* Report and free remaining plugins. */
2623 while (!list_empty(&ld->plugins->plugins)) {
2624 p = list_pop(&ld->plugins->plugins, struct plugin, list);
2625 log_debug(ld->log,
2626 "%s: failed to self-terminate in time, killing.",
2627 p->shortname);
2628 tal_free(p);
2629 }
2630 }
2631}
2632
2633static void dev_save_plugin_io(struct plugins *plugins,
2634 const char *type,

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