lightningd/subd: add a context to requests.

If a peer dies, and then we get a reply, that can cause access after free.
The usual way to handle this is to make the request a child of the peer,
but in fact we still want to catch (and disard) it, so it's a little
more complex internally.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-04-01 21:28:30 +10:30
parent a815500653
commit fed25cc540
6 changed files with 57 additions and 21 deletions

View File

@@ -97,7 +97,7 @@ void hsm_init(struct lightningd *ld, bool newdir)
else
create = (access("hsm_secret", F_OK) != 0);
subd_req(ld->hsm, take(towire_hsmctl_init(ld->hsm, create)),
subd_req(ld->hsm, ld->hsm, take(towire_hsmctl_init(ld->hsm, create)),
-1, 0, hsm_init_done, ld);
if (io_loop(NULL, NULL) != ld->hsm)