gossipd: have master explicitly tell us when peer is disconnected.

Currently we intuit it from the fd being closed, but that may happen out
of order with when the master thinks it's dead.

So now if the gossip fd closes we just ignore it, and we'll get a
notification from the master when the peer is disconnected.

The notification is slightly ugly in that we have to disable it for
a channel when we manually hand the channel back to gossipd.

Note: as stands, this is racy with reconnects.  See the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-04-26 14:21:01 +09:30
parent 1e282ecb7a
commit be1f33b265
9 changed files with 76 additions and 21 deletions

View File

@@ -237,7 +237,9 @@ wallet_commit_channel(struct lightningd *ld,
final_key_idx, false,
NULL, /* No commit sent yet */
uc->first_blocknum,
feerate, feerate);
feerate, feerate,
/* We are connected */
true);
/* Now we finally put it in the database. */
wallet_channel_insert(ld->wallet, channel);
@@ -546,7 +548,9 @@ static void opening_channel_errmsg(struct uncommitted_channel *uc,
const u8 *err_for_them)
{
if (peer_fd == -1) {
u8 *msg = towire_gossipctl_peer_disconnected(tmpctx, &uc->peer->id);
log_info(uc->log, "%s", desc);
subd_send_msg(uc->peer->ld->gossip, msg);
if (uc->fc)
command_fail(uc->fc->cmd, "%s", desc);
} else {