mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
channeld: fix intermittant failure on reading init msg from master.
As tracked down by Christian; by setting up the master conn first, we make the master fd async. This means that the synchronous read (in init_channel) can fail with -EAGAIN, and indeed, Christian saw this when not running under valgrind. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
249085ac10
commit
9ec804341c
@ -1934,6 +1934,12 @@ out_next:
|
||||
return daemon_conn_read_next(conn, master);
|
||||
}
|
||||
|
||||
static void master_gone(struct io_conn *unused, struct daemon_conn *dc)
|
||||
{
|
||||
/* Can't tell master, it's gone. */
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* We do this synchronously. */
|
||||
static void init_channel(struct peer *peer)
|
||||
{
|
||||
@ -2001,6 +2007,10 @@ static void init_channel(struct peer *peer)
|
||||
status_failed(WIRE_CHANNEL_BAD_COMMAND, "Init: %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
/* After this we'll be async, so set up now. */
|
||||
daemon_conn_init(peer, &peer->master, REQ_FD, req_in, master_gone);
|
||||
status_setup_async(&peer->master);
|
||||
|
||||
status_trace("init %s: remote_per_commit = %s, old_remote_per_commit = %s"
|
||||
" next_idx_local = %"PRIu64
|
||||
" next_idx_remote = %"PRIu64
|
||||
@ -2059,12 +2069,6 @@ static void init_channel(struct peer *peer)
|
||||
}
|
||||
|
||||
#ifndef TESTING
|
||||
static void master_gone(struct io_conn *unused, struct daemon_conn *dc)
|
||||
{
|
||||
/* Can't tell master, it's gone. */
|
||||
exit(2);
|
||||
}
|
||||
|
||||
static void gossip_gone(struct io_conn *unused, struct daemon_conn *dc)
|
||||
{
|
||||
status_failed(WIRE_CHANNEL_GOSSIP_BAD_MESSAGE,
|
||||
@ -2088,9 +2092,6 @@ int main(int argc, char *argv[])
|
||||
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
|
||||
| SECP256K1_CONTEXT_SIGN);
|
||||
|
||||
daemon_conn_init(peer, &peer->master, REQ_FD, req_in, master_gone);
|
||||
status_setup_async(&peer->master);
|
||||
|
||||
peer->num_pings_outstanding = 0;
|
||||
timers_init(&peer->timers, time_mono());
|
||||
peer->commit_timer = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user