From 7b56b2b8ce0e447f59da04e8e47f3ab0de1755dd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 16 Apr 2021 14:01:26 +0930 Subject: [PATCH] gossipd: don't start listening to connectd until we get init message. This was always a theoretical race, but with the next change we actually hit it under valgrind. Signed-off-by: Rusty Russell --- gossipd/gossipd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index b8e6fc065..1990a53e0 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1155,6 +1155,10 @@ static struct io_plan *gossip_init(struct io_conn *conn, /* Fire up the seeker! */ daemon->seeker = new_seeker(daemon); + /* connectd is already started, and uses this fd to ask us things. */ + daemon->connectd = daemon_conn_new(daemon, CONNECTD_FD, + connectd_req, NULL, daemon); + return daemon_conn_read_next(conn, daemon->master); } @@ -1952,10 +1956,6 @@ int main(int argc, char *argv[]) status_setup_async(daemon->master); - /* connectd is already started, and uses this fd to ask us things. */ - daemon->connectd = daemon_conn_new(daemon, CONNECTD_FD, - connectd_req, NULL, daemon); - /* This loop never exits. io_loop() only returns if a timer has * expired, or io_break() is called, or all fds are closed. We don't * use io_break and closing the lightningd fd calls master_gone()