mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
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:
committed by
Christian Decker
parent
d0f68ffb15
commit
d7b5882f61
@@ -1328,30 +1328,20 @@ void route_prune(struct routing_state *rstate)
|
|||||||
if (!chan->public)
|
if (!chan->public)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
if (chan->connections[0]->last_timestamp < highwater
|
||||||
struct node_connection *nc = chan->connections[i];
|
&& chan->connections[1]->last_timestamp < highwater) {
|
||||||
|
|
||||||
if (!nc)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (nc->last_timestamp > highwater) {
|
|
||||||
/* Still alive */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_trace(
|
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,
|
type_to_string(trc, struct short_channel_id,
|
||||||
&chan->scid),
|
&chan->scid),
|
||||||
nc->flags & 0x1,
|
now - chan->connections[0]->last_timestamp,
|
||||||
now - nc->last_timestamp);
|
now - chan->connections[1]->last_timestamp);
|
||||||
|
|
||||||
/* This may free nodes, so do outside loop. */
|
/* This may perturb iteration so do outside loop. */
|
||||||
tal_steal(pruned, nc);
|
tal_steal(pruned, chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This frees all the node_connections: may free routing_channel and
|
/* This frees all the routing_channels and maybe even nodes. */
|
||||||
* even nodes. */
|
|
||||||
tal_free(pruned);
|
tal_free(pruned);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1898,15 +1898,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
l3.stop()
|
l3.stop()
|
||||||
|
|
||||||
l1.daemon.wait_for_logs([
|
l1.daemon.wait_for_log("Pruning channel {} from network view".format(scid2))
|
||||||
"Pruning channel {}/{} from network view".format(scid2, 0),
|
l2.daemon.wait_for_log("Pruning channel {} from network view".format(scid2))
|
||||||
"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),
|
|
||||||
])
|
|
||||||
|
|
||||||
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 l1.rpc.listchannels()['channels']]
|
||||||
assert scid2 not in [c['short_channel_id'] for c in l2.rpc.listchannels()['channels']]
|
assert scid2 not in [c['short_channel_id'] for c in l2.rpc.listchannels()['channels']]
|
||||||
|
|||||||
Reference in New Issue
Block a user