mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 08:04:26 +01:00
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>
35 lines
808 B
C
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;
|
|
}
|