Skip to content

Commit

Permalink
askrene: memleak: scan reserved htable
Browse files Browse the repository at this point in the history
Signed-off-by: Lagrang3 <[email protected]>
  • Loading branch information
Lagrang3 authored and rustyrussell committed Aug 12, 2024
1 parent cf3375c commit 5073942
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/askrene/askrene.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,9 @@ static const struct plugin_command commands[] = {

static void askrene_markmem(struct plugin *plugin, struct htable *memtable)
{
layer_memleak_mark(get_askrene(plugin), memtable);
struct askrene *askrene = get_askrene(plugin);
layer_memleak_mark(askrene, memtable);
reserve_memleak_mark(askrene, memtable);
}

static const char *init(struct plugin *plugin,
Expand Down
7 changes: 7 additions & 0 deletions plugins/askrene/reserve.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <assert.h>
#include <ccan/htable/htable_type.h>
#include <common/gossmap.h>
#include <common/memleak.h>
#include <plugins/askrene/askrene.h>
#include <plugins/askrene/reserve.h>

/* Hash table for reservations */
Expand Down Expand Up @@ -138,3 +140,8 @@ void reserves_clear_capacities(struct reserve_htable *reserved,
capacities[idx] = 0;
}
}

void reserve_memleak_mark(struct askrene *askrene, struct htable *memtable)
{
memleak_scan_htable(memtable, &askrene->reserved->raw);
}
3 changes: 3 additions & 0 deletions plugins/askrene/reserve.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ size_t reserves_remove(struct reserve_htable *reserved,
void reserves_clear_capacities(struct reserve_htable *reserved,
const struct gossmap *gossmap,
fp16_t *capacities);

/* Scan for memleaks */
void reserve_memleak_mark(struct askrene *askrene, struct htable *memtable);
#endif /* LIGHTNING_PLUGINS_ASKRENE_RESERVE_H */

0 comments on commit 5073942

Please sign in to comment.