From 763697eb4cc83f76a64130117a1179b8b1057fa3 Mon Sep 17 00:00:00 2001 From: Rusty Russell <rusty@rustcorp.com.au> Date: Wed, 29 May 2019 14:05:47 +0930 Subject: [PATCH] gossipd: fix gossip_store calling delete. Now we handle node_announcements properly, we have a failure case where we try to move them when a channel is deleted while loading the store. We're going to remove this soon, in favor of in-place delete, so workaround this for now to avoid an assert() when we try to write to the store while loading. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> --- gossipd/gossip_store.c | 6 ++++++ gossipd/gossip_store.h | 3 +++ gossipd/routing.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index 871dc008a..f6986ee63 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -645,3 +645,9 @@ out: gs->len); gs->writable = true; } + +/* FIXME: Remove */ +bool gossip_store_loading(const struct gossip_store *gs) +{ + return !gs->writable; +} diff --git a/gossipd/gossip_store.h b/gossipd/gossip_store.h index 317bd35e8..743e6b0c5 100644 --- a/gossipd/gossip_store.h +++ b/gossipd/gossip_store.h @@ -74,4 +74,7 @@ bool gossip_store_compact(struct gossip_store *gs, */ int gossip_store_readonly_fd(struct gossip_store *gs); +/* FIXME: Remove */ +bool gossip_store_loading(const struct gossip_store *gs); + #endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */ diff --git a/gossipd/routing.c b/gossipd/routing.c index a4bd31287..ada96cec2 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -337,6 +337,12 @@ static void remove_chan_from_node(struct routing_state *rstate, if (!node->bcast.index) return; + /* FIXME: Remove when we get rid of WIRE_GOSSIP_STORE_CHANNEL_DELETE. + * For the moment, it can cause us to try to write to the store. */ + (void)WIRE_GOSSIP_STORE_CHANNEL_DELETE; + if (gossip_store_loading(rstate->broadcasts->gs)) + return; + /* Removed only public channel? Remove node announcement. */ if (!node_has_broadcastable_channels(node)) { broadcast_del(rstate->broadcasts, &node->bcast);