mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-12-27 09:04:40 +01:00
a93c49ca65
dev_blackhole_fd was a hack, and doesn't work well now we are async (it worked for sync comms in per-peer daemons, but now we could sneak through a read before we get to the next write). So, make explicit flags and use them. This is much easier now we have all peer comms in one place. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
34 lines
971 B
C
34 lines
971 B
C
#ifndef LIGHTNING_COMMON_DEV_DISCONNECT_H
|
|
#define LIGHTNING_COMMON_DEV_DISCONNECT_H
|
|
#include "config.h"
|
|
#include <stdbool.h>
|
|
|
|
#if DEVELOPER
|
|
struct node_id;
|
|
|
|
enum dev_disconnect {
|
|
/* Do nothing. */
|
|
DEV_DISCONNECT_NORMAL = '=',
|
|
/* Close connection before sending packet. */
|
|
DEV_DISCONNECT_BEFORE = '-',
|
|
/* Close connection after sending packet. */
|
|
DEV_DISCONNECT_AFTER = '+',
|
|
/* Swallow all writes from now on, and do no more reads. */
|
|
DEV_DISCONNECT_BLACKHOLE = '0',
|
|
/* Don't use connection after sending packet, but don't close. */
|
|
DEV_DISCONNECT_DISABLE_AFTER = 'x',
|
|
};
|
|
|
|
/* Force a close fd before or after a certain packet type */
|
|
enum dev_disconnect dev_disconnect(const struct node_id *id, int pkt_type);
|
|
|
|
/* Make next write on fd fail as if they'd disconnected. */
|
|
void dev_sabotage_fd(int fd, bool close_fd);
|
|
|
|
/* For debug code to set in daemon. */
|
|
void dev_disconnect_init(int fd);
|
|
|
|
#endif /* DEVELOPER */
|
|
|
|
#endif /* LIGHTNING_COMMON_DEV_DISCONNECT_H */
|