connectd: temporarily have two fds to gossipd.

We want to stream gossip through this, but currently connectd treats the
fd as synchronous.  While we work on getting rid of that, it's easiest to
have two fds.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-01-25 06:36:52 +10:30
parent 4dc72dd829
commit bba468a51c
8 changed files with 40 additions and 13 deletions

View File

@@ -403,9 +403,9 @@ static void connect_init_done(struct subd *connectd,
io_break(connectd);
}
int connectd_init(struct lightningd *ld)
int connectd_init(struct lightningd *ld, int *gossipd_fd2)
{
int fds[2];
int fds[2], fds2[2];
u8 *msg;
int hsmfd;
struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
@@ -418,11 +418,16 @@ int connectd_init(struct lightningd *ld)
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
fatal("Could not socketpair for connectd<->gossipd");
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds2) != 0)
fatal("Could not socketpair for connectd<->gossipd 2");
hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH);
ld->connectd = new_global_subd(ld, "lightning_connectd",
connectd_wire_name, connectd_msg,
take(&hsmfd), take(&fds[1]),
take(&hsmfd),
take(&fds[1]),
take(&fds2[1]),
#if DEVELOPER
/* Not take(): we share it */
ld->dev_disconnect_fd >= 0 ?
@@ -463,6 +468,7 @@ int connectd_init(struct lightningd *ld)
/* Wait for init_reply */
io_loop(NULL, NULL);
*gossipd_fd2 = fds2[0];
return fds[0];
}