Files
lightning/common/peer_io.c
Rusty Russell e37a638c0c connectd: do nagle by packet type.
channeld can't do it any more: it's using local sockets.  Connectd
can do it, and simply does it by type.

Amazingly, on my machine the timing change *always* caused
test_channel_receivable() to fail, due to a latent race.

Includes feedback from @cdecker.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-01-20 15:24:06 +10:30

35 lines
808 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);
if (!wire_sync_write(pps->peer_fd, msg))
peer_failed_connection_lost();
}
u8 *peer_read(const tal_t *ctx, struct per_peer_state *pps)
{
u8 *dec = wire_sync_read(ctx, pps->peer_fd);
if (!dec)
peer_failed_connection_lost();
status_peer_io(LOG_IO_IN, NULL, dec);
return dec;
}