Browse Source

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

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
d7b5882f61
  1. 26
      gossipd/routing.c
  2. 11
      tests/test_lightningd.py

26
gossipd/routing.c

@ -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);
}

11
tests/test_lightningd.py

@ -1898,15 +1898,8 @@ class LightningDTests(BaseLightningDTests):
time.sleep(1)
l3.stop()
l1.daemon.wait_for_logs([
"Pruning channel {}/{} from network view".format(scid2, 0),
"Pruning channel {}/{} from network view".format(scid2, 1),
])
l2.daemon.wait_for_logs([
"Pruning channel {}/{} from network view".format(scid2, 0),
"Pruning channel {}/{} from network view".format(scid2, 1),
])
l1.daemon.wait_for_log("Pruning channel {} from network view".format(scid2))
l2.daemon.wait_for_log("Pruning channel {} from network view".format(scid2))
assert scid2 not in [c['short_channel_id'] for c in l1.rpc.listchannels()['channels']]
assert scid2 not in [c['short_channel_id'] for c in l2.rpc.listchannels()['channels']]

Loading…
Cancel
Save