mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
dev_disconnect: support 'permfail' line to permanently fail peer.
The master daemon checks for this after a subdaemon dies. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f5f8ca5352
commit
99581bd709
@ -23,6 +23,7 @@
|
||||
#include <lightningd/channel/gen_channel_wire.h>
|
||||
#include <lightningd/closing/gen_closing_wire.h>
|
||||
#include <lightningd/commit_tx.h>
|
||||
#include <lightningd/dev_disconnect.h>
|
||||
#include <lightningd/funding_tx.h>
|
||||
#include <lightningd/gen_peer_state_names.h>
|
||||
#include <lightningd/gossip/gen_gossip_wire.h>
|
||||
@ -151,6 +152,11 @@ void peer_fail_transient(struct peer *peer, const char *fmt, ...)
|
||||
logv_add(peer->log, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (dev_disconnect_permanent(peer->ld)) {
|
||||
peer_internal_error(peer, "dev_disconnect permfail");
|
||||
return;
|
||||
}
|
||||
|
||||
peer->owner = NULL;
|
||||
|
||||
/* If we haven't reached awaiting locked, we don't need to reconnect */
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ccan/io/fdpass/fdpass.h>
|
||||
#include <ccan/io/io.h>
|
||||
#include <ccan/mem/mem.h>
|
||||
#include <ccan/noerr/noerr.h>
|
||||
#include <ccan/take/take.h>
|
||||
#include <ccan/tal/path/path.h>
|
||||
@ -510,3 +511,20 @@ char *opt_subd_dev_disconnect(const char *optarg, struct lightningd *ld)
|
||||
optarg, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If test specified that this disconnection should cause permanent failure */
|
||||
bool dev_disconnect_permanent(struct lightningd *ld)
|
||||
{
|
||||
char permfail[strlen("PERMFAIL")];
|
||||
int r;
|
||||
|
||||
if (ld->dev_disconnect_fd == -1)
|
||||
return false;
|
||||
|
||||
r = read(ld->dev_disconnect_fd, permfail, sizeof(permfail));
|
||||
if (r < 0)
|
||||
fatal("Reading dev_disconnect file: %s", strerror(errno));
|
||||
lseek(ld->dev_disconnect_fd, -r, SEEK_CUR);
|
||||
|
||||
return memeq(permfail, r, "permfail", strlen("permfail"));
|
||||
}
|
||||
|
@ -135,4 +135,6 @@ void subd_shutdown(struct subd *subd, unsigned int seconds);
|
||||
|
||||
char *opt_subd_debug(const char *optarg, struct lightningd *ld);
|
||||
char *opt_subd_dev_disconnect(const char *optarg, struct lightningd *ld);
|
||||
|
||||
bool dev_disconnect_permanent(struct lightningd *ld);
|
||||
#endif /* LIGHTNING_LIGHTNINGD_SUBD_H */
|
||||
|
Loading…
Reference in New Issue
Block a user