Browse Source

lightningd: don't try to delete peer from db on shutdown if it's opening.

Fortunately, we hit the assert in wallet_peer_delete() if this happens,
since there are still active channels.

This latent bug becomes far more likely in followup patches, where
openingd is used for idle peers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
c05bc7c8ab
  1. 15
      lightningd/lightningd.c
  2. 4
      lightningd/opening_control.c

15
lightningd/lightningd.c

@ -224,11 +224,16 @@ static void shutdown_subdaemons(struct lightningd *ld)
} }
/* Freeing uncommitted channel will free peer. */ /* Freeing uncommitted channel will free peer. */
if (p->uncommitted_channel) if (p->uncommitted_channel) {
tal_free(p->uncommitted_channel); struct uncommitted_channel *uc = p->uncommitted_channel;
else
/* Removes itself from list as we free it */ /* Setting to NULL stops destroy_uncommitted_channel
tal_free(p); * from trying to remove peer from db! */
p->uncommitted_channel = NULL;
tal_free(uc);
}
/* Removes itself from list as we free it */
tal_free(p);
} }
db_commit_transaction(ld->wallet->db); db_commit_transaction(ld->wallet->db);
} }

4
lightningd/opening_control.c

@ -584,6 +584,10 @@ static void destroy_uncommitted_channel(struct uncommitted_channel *uc)
subd_release_channel(openingd, uc); subd_release_channel(openingd, uc);
} }
/* This is how shutdown_subdaemons tells us not to delete from db! */
if (!uc->peer->uncommitted_channel)
return;
uc->peer->uncommitted_channel = NULL; uc->peer->uncommitted_channel = NULL;
maybe_delete_peer(uc->peer); maybe_delete_peer(uc->peer);

Loading…
Cancel
Save