mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
2ab5603624
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>
36 lines
871 B
C
36 lines
871 B
C
#include "config.h"
|
|
#include <ccan/read_write_all/read_write_all.h>
|
|
#include <common/cryptomsg.h>
|
|
#include <common/peer_failed.h>
|
|
#include <common/peer_io.h>
|
|
#include <common/per_peer_state.h>
|
|
#include <common/status.h>
|
|
#include <errno.h>
|
|
#include <inttypes.h>
|
|
#include <netinet/in.h>
|
|
#include <netinet/tcp.h>
|
|
#include <sys/socket.h>
|
|
#include <wire/wire.h>
|
|
#include <wire/wire_io.h>
|
|
#include <wire/wire_sync.h>
|
|
|
|
void peer_write(struct per_peer_state *pps, const void *msg TAKES)
|
|
{
|
|
status_peer_io(LOG_IO_OUT, NULL, msg);
|
|
|
|
/* 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)
|
|
{
|
|
u8 *msg = wire_sync_read(ctx, pps->peer_fd);
|
|
if (!msg)
|
|
peer_failed_connection_lost();
|
|
|
|
status_peer_io(LOG_IO_IN, NULL, msg);
|
|
|
|
return msg;
|
|
}
|