diff --git a/connectd/connectd.c b/connectd/connectd.c index b2b07eaab..71f0d8976 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -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)) diff --git a/connectd/connectd.h b/connectd/connectd.h index 825a21891..ce1fd44e2 100644 --- a/connectd/connectd.h +++ b/connectd/connectd.h @@ -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 }; diff --git a/connectd/connectd_wire.csv b/connectd/connectd_wire.csv index 5b0950f93..dbb660095 100644 --- a/connectd/connectd_wire.csv +++ b/connectd/connectd_wire.csv @@ -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 diff --git a/connectd/multiplex.c b/connectd/multiplex.c index c39c35ea0..959638e08 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -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); diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index df6993c81..1f8e80c74 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -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); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index f7ffa99eb..c55e861d2 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -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 diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 973db2a7c..a90f13309 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -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 */ diff --git a/lightningd/options.c b/lightningd/options.c index e75685492..635feb40e 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -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 */