lightningd: add --dev-no-ping-timer to avoid ping response timeouts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-03-25 13:41:55 +10:30
parent a35e1b23e6
commit ea7120a313
8 changed files with 21 additions and 4 deletions

View File

@ -1517,7 +1517,7 @@ static void connect_init(struct daemon *daemon, const u8 *msg)
struct wireaddr *announceable;
char *tor_password;
bool dev_fast_gossip;
bool dev_disconnect;
bool dev_disconnect, dev_no_ping_timer;
char *errstr;
/* Fields which require allocation are allocated off daemon */
@ -1536,15 +1536,17 @@ static void connect_init(struct daemon *daemon, const u8 *msg)
&daemon->websocket_helper,
&daemon->websocket_port,
&dev_fast_gossip,
&dev_disconnect)) {
&dev_disconnect,
&dev_no_ping_timer)) {
/* This is a helper which prints the type expected and the actual
* message, then exits (it should never be called!). */
master_badmsg(WIRE_CONNECTD_INIT, msg);
}
#if DEVELOPER
/*~ Clearly mark this as a developer-only flag! */
/*~ Clearly mark these as developer-only flags! */
daemon->dev_fast_gossip = dev_fast_gossip;
daemon->dev_no_ping_timer = dev_no_ping_timer;
#endif
if (!pubkey_from_node_id(&daemon->mykey, &daemon->id))

View File

@ -191,6 +191,8 @@ struct daemon {
#if DEVELOPER
/* Hack to speed up gossip timer */
bool dev_fast_gossip;
/* Hack to avoid ping timeouts */
bool dev_no_ping_timer;
#endif
};

View File

@ -25,6 +25,7 @@ msgdata,connectd_init,websocket_port,u16,
msgdata,connectd_init,dev_fast_gossip,bool,
# If this is set, then fd 5 is dev_disconnect_fd.
msgdata,connectd_init,dev_disconnect,bool,
msgdata,connectd_init,dev_no_ping_timer,bool,
# Connectd->master, here are the addresses I bound, can announce.
msgtype,connectd_init_reply,2100

1 #include <bitcoin/block.h>
25 # If this is set, then fd 5 is dev_disconnect_fd.
26 msgdata,connectd_init,dev_disconnect,bool,
27 # Connectd->master, here are the addresses I bound, can announce. msgdata,connectd_init,dev_no_ping_timer,bool,
28 # Connectd->master, here are the addresses I bound, can announce.
29 msgtype,connectd_init_reply,2100
30 msgdata,connectd_init_reply,num_bindings,u16,
31 msgdata,connectd_init_reply,bindings,wireaddr_internal,num_bindings

View File

@ -391,6 +391,10 @@ static void send_ping(struct peer *peer);
static void set_ping_timer(struct peer *peer)
{
if (IFDEV(peer->daemon->dev_no_ping_timer, false)) {
peer->ping_timer = NULL;
return;
}
peer->ping_timer = new_reltimer(&peer->daemon->timers, peer,
time_from_sec(15 + pseudorand(30)),
send_ping, peer);

View File

@ -558,7 +558,8 @@ int connectd_init(struct lightningd *ld)
websocket_helper_path,
ld->websocket_port,
IFDEV(ld->dev_fast_gossip, false),
IFDEV(ld->dev_disconnect_fd >= 0, false));
IFDEV(ld->dev_disconnect_fd >= 0, false),
IFDEV(ld->dev_no_ping_timer, false));
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
connect_init_done, NULL);

View File

@ -136,6 +136,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->dev_ignore_modern_onion = false;
ld->dev_ignore_obsolete_onion = false;
ld->dev_disable_commit = -1;
ld->dev_no_ping_timer = false;
#endif
/*~ These are CCAN lists: an embedded double-linked list. It's not

View File

@ -267,6 +267,9 @@ struct lightningd {
/* Tell channeld to disable commits after this many. */
int dev_disable_commit;
/* Tell channeld not to worry about pings. */
bool dev_no_ping_timer;
#endif /* DEVELOPER */
/* tor support */

View File

@ -740,6 +740,9 @@ static void dev_register_opts(struct lightningd *ld)
opt_set_intval, opt_show_intval,
&ld->dev_disable_commit,
"Disable commit timer after this many commits");
opt_register_noarg("--dev-no-ping-timer", opt_set_bool,
&ld->dev_no_ping_timer,
"Don't hang up if we don't get a ping response");
}
#endif /* DEVELOPER */