From af8eabb9a7cbe108adb80b8ec1f9a1bbbd9f293b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 3 Dec 2020 11:51:35 +1030 Subject: [PATCH] common/daemon: remove notifiers on root at cleanup. Under some circumstances, valgrind complains. Signed-off-by: Rusty Russell --- common/daemon.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/daemon.c b/common/daemon.c index 7d8ee1e24..09ef0b228 100644 --- a/common/daemon.c +++ b/common/daemon.c @@ -119,6 +119,12 @@ static void add_steal_notifiers(const tal_t *root) for (const tal_t *i = tal_first(root); i; i = tal_next(i)) add_steal_notifiers(i); } + +static void remove_steal_notifiers(void) +{ + /* We remove this from root, assuming everything else freed. */ + tal_del_notifier(NULL, add_steal_notifier); +} #endif void daemon_setup(const char *argv0, @@ -155,6 +161,10 @@ void daemon_setup(const char *argv0, void daemon_shutdown(void) { common_shutdown(); + +#if DEVELOPER && BACKTRACE_SUPPORTED + remove_steal_notifiers(); +#endif } void daemon_maybe_debug(char *argv[])