Skip to content

Commit 1751f77

Browse files
committed
Avoid polling completed futures in the background-processor
`poll`ing completed futures invokes undefined behavior in Rust (panics, etc, obviously not memory corruption as its not unsafe). Sadly, in our futures-based version of `lightning-background-processor` we have one case where we can `poll` a completed future - if the timer for the network graph prune + persist completes without a network graph to prune + persist we'll happily poll the same future over and over again, likely panicing in user code.
1 parent af76fac commit 1751f77

File tree

1 file changed

+1
-1
lines changed
  • lightning-background-processor/src

1 file changed

+1
-1
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ macro_rules! define_run_body {
349349
log_error!($logger, "Error: Failed to persist network graph, check your disk and permissions {}", e)
350350
}
351351

352-
last_prune_call = $get_timer(NETWORK_PRUNE_TIMER);
353352
have_pruned = true;
354353
}
354+
last_prune_call = $get_timer(NETWORK_PRUNE_TIMER);
355355
}
356356

357357
if $timer_elapsed(&mut last_scorer_persist_call, SCORER_PERSIST_TIMER) {

0 commit comments

Comments
 (0)