connectd: give connections a chance to drain when lightningd says to disconnect, or peer disconnects.

We want to avoid lost messages in the common cases.

This generalizes our drain code, by giving the subds each 5 seconds to
close themselves, but continue to allow them to send us traffic (if
peer is still connected) and continue to send them traffic.

We continue to send traffic *out* to the peer (if it's still
connected), until all subds are gone.  We still have a 5 second timer
to close the connection to peer.

On reconnects, we don't do this "drain period" on reconnects: we kill
immediately.

We fix up one test which was looking for the "disconnect" message
explicitly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-07-18 21:42:27 +09:30
committed by neil saitug
parent 9cff125590
commit 719d1384d1
5 changed files with 97 additions and 42 deletions

View File

@@ -2869,8 +2869,8 @@ def test_opener_feerate_reconnect(node_factory, bitcoind):
l2.daemon.wait_for_log(r'dev_disconnect: \-WIRE_COMMITMENT_SIGNED')
# Wait until they reconnect.
l1.daemon.wait_for_log('Peer transient failure in CHANNELD_NORMAL')
l1.daemon.wait_for_log('peer_disconnect_done')
l1.daemon.wait_for_logs(['Peer transient failure in CHANNELD_NORMAL',
'peer_disconnect_done'])
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'])
# Should work normally.