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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-04-16 14:01:26 +09:30
parent 32d650f9df
commit 7b56b2b8ce
1 changed files with 4 additions and 4 deletions

View File

@ -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()