mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
plugins: Fix undefined deallocation order in struct plugins
We use the new function `plugins_free` to define the correct deallocation order on shutdown, since under normal operation the allocation tree is organized to allow plugins to terminate and automatically free all dependent resources. During shutdown the deallocation order is under-defined since siblings may get freed in any order, but we implicitly rely on them staying around.
This commit is contained in:
committed by
Rusty Russell
parent
284bd7de0c
commit
27ea47ae37
@@ -56,6 +56,19 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
||||
return p;
|
||||
}
|
||||
|
||||
void plugins_free(struct plugins *plugins)
|
||||
{
|
||||
struct plugin *p;
|
||||
/* Plugins are usually the unit of allocation, and they are internally
|
||||
* consistent, so let's free each plugin first. */
|
||||
while (!list_empty(&plugins->plugins)) {
|
||||
p = list_pop(&plugins->plugins, struct plugin, list);
|
||||
tal_free(p);
|
||||
}
|
||||
|
||||
tal_free(plugins);
|
||||
}
|
||||
|
||||
static void destroy_plugin(struct plugin *p)
|
||||
{
|
||||
struct plugin_rpccall *call;
|
||||
|
||||
Reference in New Issue
Block a user