Browse Source

subd: add transaction to subd exit corner case.

As demonstrated in the test at the end of this series, openingd dying
spontaneously causes the conn to be freed which causes the subd to be
destroyed, which fails the peer, which hits the db.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
899bf3fde9
  1. 10
      lightningd/subd.c

10
lightningd/subd.c

@ -548,10 +548,20 @@ static void destroy_subd(struct subd *sd)
if (sd->peer) {
/* Don't loop back when we fail it. */
struct peer *peer = sd->peer;
struct db *db = sd->ld->wallet->db;
bool outer_transaction;
sd->peer = NULL;
/* We can be freed both inside msg handling, or spontaneously. */
outer_transaction = db->in_transaction;
if (!outer_transaction)
db_begin_transaction(db);
peer_fail_transient(peer,
"Owning subdaemon %s died (%i)",
sd->name, status);
if (!outer_transaction)
db_commit_transaction(db);
}
if (sd->must_not_exit) {

Loading…
Cancel
Save