From 2db77f5d1d45f36dd276cde6f81b3448a1075392 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 24 Aug 2018 14:50:06 +0930 Subject: [PATCH] gossipd: minor modifications for memleak detection to work. 1. Move the list to the start of `struct peer`: memleak walks the list correctly this way. 2. Don't create tal parent loop daemon->conn->daemon. The second one is silly anyway: we exit via master_gone when the master conn is closed. Signed-off-by: Rusty Russell --- gossipd/gossip.c | 7 ++----- lightningd/test/run-param.c | 4 ---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 23910bc85..1b0ffcd8f 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -119,11 +119,11 @@ struct daemon { }; struct peer { - struct daemon *daemon; - /* daemon->peers */ struct list_node list; + struct daemon *daemon; + /* The ID of the peer (not necessarily unique, in transit!) */ struct pubkey id; @@ -2261,9 +2261,6 @@ int main(int argc, char *argv[]) daemon_conn_init(daemon, &daemon->connectd, CONNECTD_FD, connectd_req, NULL); - /* When conn closes, everything is freed. */ - tal_steal(daemon->master.conn, daemon); - for (;;) { struct timer *expired = NULL; io_loop(&daemon->timers, &expired); diff --git a/lightningd/test/run-param.c b/lightningd/test/run-param.c index f6b0bb8be..bd2756250 100644 --- a/lightningd/test/run-param.c +++ b/lightningd/test/run-param.c @@ -48,10 +48,6 @@ void command_fail_detailed(struct command *cmd, int code, /* Generated stub for fmt_wireaddr_without_port */ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED) { fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); } -/* Generated stub for json_tok_wtx */ -bool json_tok_wtx(struct wallet_tx * tx UNNEEDED, const char * buffer UNNEEDED, - const jsmntok_t * sattok UNNEEDED, u64 max UNNEEDED) -{ fprintf(stderr, "json_tok_wtx called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ struct json {