mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-19 13:04:37 +01:00
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>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user