subd: simplify and cleanup lifetime handling.

There are now only two kinds of subdaemons: global ones (hsmd, gossipd) and
per-peer ones.  We can handle many callbacks internally now.

We can have a handler to set a new peer owner, and automatically do
the cleanup of the old one if necessary, since we now know which ones
are per-peer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-10-12 17:05:03 +10:30
committed by Christian Decker
parent a117d595a4
commit 5a256c724a
7 changed files with 194 additions and 166 deletions

View File

@@ -1252,16 +1252,15 @@ class LightningDTests(BaseLightningDTests):
# Reconnect.
l1.rpc.connect(l2.info['id'], 'localhost:{}'.format(l2.info['port']))
# We should get a message about old one exiting.
# We should get a message about reconnecting.
l2.daemon.wait_for_log('Peer has reconnected, state OPENINGD')
l2.daemon.wait_for_log('Owning subdaemon lightning_openingd died')
# Should work fine.
l1.rpc.fundchannel(l2.info['id'], 20000)
l1.daemon.wait_for_log('sendrawtx exit 0')
# Just to be sure, second openingd hand over to channeld.
l2.daemon.wait_for_log('Subdaemon lightning_openingd died \(0\)')
l2.daemon.wait_for_log('lightning_openingd.*REPLY WIRE_OPENING_FUNDEE_REPLY with 2 fds')
def test_reconnect_normal(self):
# Should reconnect fine even if locked message gets lost.