peer_failed: write error message to peer directly.

We currently hand the error back to the master, who then stores it for
future connections and hands it back to another openingd to send and exit.

Just send directly; it's more reliable and simpler.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-08-09 09:55:29 +09:30
committed by Christian Decker
parent d8d4b19f3a
commit b4e6a0fcad
2 changed files with 8 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
#include <ccan/tal/str/str.h> #include <ccan/tal/str/str.h>
#include <common/crypto_sync.h>
#include <common/gen_peer_status_wire.h> #include <common/gen_peer_status_wire.h>
#include <common/gen_status_wire.h> #include <common/gen_status_wire.h>
#include <common/peer_billboard.h> #include <common/peer_billboard.h>
@@ -15,16 +16,20 @@ void peer_failed_(int peer_fd, int gossip_fd,
{ {
va_list ap; va_list ap;
const char *desc; const char *desc;
u8 *msg; u8 *msg, *err;
va_start(ap, fmt); va_start(ap, fmt);
desc = tal_vfmt(NULL, fmt, ap); desc = tal_vfmt(NULL, fmt, ap);
va_end(ap); va_end(ap);
/* Tell peer the error. */
err = towire_errorfmt(desc, channel_id, "%s", desc);
sync_crypto_write(cs, peer_fd, err);
/* Tell master the error so it can re-xmit. */
msg = towire_status_peer_error(NULL, channel_id, msg = towire_status_peer_error(NULL, channel_id,
desc, cs, desc, cs,
towire_errorfmt(desc, channel_id, err);
"%s", desc));
peer_billboard(true, desc); peer_billboard(true, desc);
tal_free(desc); tal_free(desc);
status_send_fatal(take(msg), peer_fd, gossip_fd); status_send_fatal(take(msg), peer_fd, gossip_fd);

View File

@@ -418,9 +418,6 @@ void channel_errmsg(struct channel *channel,
channel_fail_permanent(channel, "%s: %s ERROR %s", channel_fail_permanent(channel, "%s: %s ERROR %s",
channel->owner->name, channel->owner->name,
err_for_them ? "sent" : "received", desc); err_for_them ? "sent" : "received", desc);
/* Get openingd to chat with them, maybe sending error. */
peer_start_openingd(channel->peer, cs, peer_fd, gossip_fd, err_for_them);
} }
/* Connectd tells us a peer has connected: it never hands us duplicates, since /* Connectd tells us a peer has connected: it never hands us duplicates, since