subd: send versions at startup.

For channeld, we move status_setup_sync() to a more obvious place.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-04-08 15:46:49 +09:30
parent b36e9fe473
commit 8714bf903c
2 changed files with 9 additions and 2 deletions

View File

@@ -3040,8 +3040,6 @@ static void init_channel(struct peer *peer)
assert(!(fcntl(MASTER_FD, F_GETFL) & O_NONBLOCK)); assert(!(fcntl(MASTER_FD, F_GETFL) & O_NONBLOCK));
status_setup_sync(MASTER_FD);
msg = wire_sync_read(tmpctx, MASTER_FD); msg = wire_sync_read(tmpctx, MASTER_FD);
if (!fromwire_channeld_init(peer, msg, if (!fromwire_channeld_init(peer, msg,
&chainparams, &chainparams,
@@ -3225,6 +3223,8 @@ int main(int argc, char *argv[])
subdaemon_setup(argc, argv); subdaemon_setup(argc, argv);
status_setup_sync(MASTER_FD);
peer = tal(NULL, struct peer); peer = tal(NULL, struct peer);
peer->expecting_pong = false; peer->expecting_pong = false;
timers_init(&peer->timers, time_mono()); timers_init(&peer->timers, time_mono());

View File

@@ -11,6 +11,7 @@
#include <common/status.h> #include <common/status.h>
#include <common/status_wiregen.h> #include <common/status_wiregen.h>
#include <common/utils.h> #include <common/utils.h>
#include <common/version.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <wire/peer_wire.h> #include <wire/peer_wire.h>
@@ -59,6 +60,9 @@ void status_setup_sync(int fd)
assert(!status_conn); assert(!status_conn);
status_fd = fd; status_fd = fd;
setup_logging_sighandler(); setup_logging_sighandler();
/* Send version now. */
status_send(take(towire_status_version(NULL, version())));
} }
static void destroy_daemon_conn(struct daemon_conn *dc UNUSED) static void destroy_daemon_conn(struct daemon_conn *dc UNUSED)
@@ -75,6 +79,9 @@ void status_setup_async(struct daemon_conn *master)
tal_add_destructor(master, destroy_daemon_conn); tal_add_destructor(master, destroy_daemon_conn);
setup_logging_sighandler(); setup_logging_sighandler();
/* Send version now. */
status_send(take(towire_status_version(NULL, version())));
} }
void status_send(const u8 *msg TAKES) void status_send(const u8 *msg TAKES)