mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-09 15:18:09 +01:00
5889ad5fc4
To reproduce the next bug, I had to ensure that one node keeps thinking it's disconnected, then the other node reconnects, then the first node realizes it's disconnected. This code does that, adding a '0' dev-disconnect modifier. That means we fork off a process which (due to pipebuf) will accept a little data, but when the dev_disconnect file is truncated (a hacky, but effective, signalling mechanism) will exit, as if the socket finally realized it's not connected any more. The python tests hang waiting for the daemon to terminate if you leave the blackhole around; to give a clue as to what's happening in this case I moved the log dump to before killing the daemon. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
25 lines
698 B
C
25 lines
698 B
C
#ifndef LIGHTNING_COMMON_DEV_DISCONNECT_H
|
|
#define LIGHTNING_COMMON_DEV_DISCONNECT_H
|
|
#include "config.h"
|
|
#include <stdbool.h>
|
|
|
|
#define DEV_DISCONNECT_BEFORE '-'
|
|
#define DEV_DISCONNECT_AFTER '+'
|
|
#define DEV_DISCONNECT_DROPPKT '@'
|
|
#define DEV_DISCONNECT_BLACKHOLE '0'
|
|
#define DEV_DISCONNECT_NORMAL 0
|
|
|
|
/* Force a close fd before or after a certain packet type */
|
|
char dev_disconnect(int pkt_type);
|
|
|
|
/* Make next write on fd fail as if they'd disconnected. */
|
|
void dev_sabotage_fd(int fd);
|
|
|
|
/* No more data to arrive, what's written is swallowed. */
|
|
void dev_blackhole_fd(int fd);
|
|
|
|
/* For debug code to set in daemon. */
|
|
void dev_disconnect_init(int fd);
|
|
|
|
#endif /* LIGHTNING_COMMON_DEV_DISCONNECT_H */
|