peer subds: ignore failed writes.

In the case where the peer sends an error (and hangs up) immediately
after init, connectd *doesn't actually read the error* (even after all the
previous fixes so it actually receives the error!).

This is because to tried to first write WIRE_CHANNEL_REESTABLISH, and
that fails, so it never tries to read.  Generally, we should ignore
write failures; we'll find out if the socket is closed when we read
nothing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-01-11 11:47:30 +10:30
parent e366cb17f6
commit 2ab5603624

View File

@ -18,8 +18,9 @@ void peer_write(struct per_peer_state *pps, const void *msg TAKES)
{
status_peer_io(LOG_IO_OUT, NULL, msg);
if (!wire_sync_write(pps->peer_fd, msg))
peer_failed_connection_lost();
/* We ignore write errors; we might still have something to read,
* so we'd rather fail there. */
wire_sync_write(pps->peer_fd, msg);
}
u8 *peer_read(const tal_t *ctx, struct per_peer_state *pps)