routing: don't free a single nc on prune, only entire channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-03-02 19:29:17 +10:30
committed by Christian Decker
parent d0f68ffb15
commit d7b5882f61
2 changed files with 10 additions and 27 deletions

View File

@@ -1328,30 +1328,20 @@ void route_prune(struct routing_state *rstate)
if (!chan->public)
continue;
for (int i = 0; i < 2; i++) {
struct node_connection *nc = chan->connections[i];
if (!nc)
continue;
if (nc->last_timestamp > highwater) {
/* Still alive */
continue;
}
if (chan->connections[0]->last_timestamp < highwater
&& chan->connections[1]->last_timestamp < highwater) {
status_trace(
"Pruning channel %s/%d from network view (age %"PRIu64"s)",
"Pruning channel %s from network view (ages %"PRIu64" and %"PRIu64"s)",
type_to_string(trc, struct short_channel_id,
&chan->scid),
nc->flags & 0x1,
now - nc->last_timestamp);
now - chan->connections[0]->last_timestamp,
now - chan->connections[1]->last_timestamp);
/* This may free nodes, so do outside loop. */
tal_steal(pruned, nc);
/* This may perturb iteration so do outside loop. */
tal_steal(pruned, chan);
}
}
/* This frees all the node_connections: may free routing_channel and
* even nodes. */
/* This frees all the routing_channels and maybe even nodes. */
tal_free(pruned);
}