Skip to content

Commit

Permalink
Persist ChannelManager before BackgroundProcessor exits
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Jan 18, 2022
1 parent 7b6a7bb commit 4a1f87c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl BackgroundProcessor {
// Exit the loop if the background processor was requested to stop.
if stop_thread.load(Ordering::Acquire) == true {
log_trace!(logger, "Terminating background processor.");
return Ok(());
break;
}
if last_freshness_call.elapsed().as_secs() > FRESHNESS_TIMER {
log_trace!(logger, "Calling ChannelManager's timer_tick_occurred");
Expand Down Expand Up @@ -269,6 +269,10 @@ impl BackgroundProcessor {
}
}
}
// After we exit, ensure we persist the ChannelManager one final time - this avoids
// some races where users quit while channel updates were in-flight, with
// ChannelMonitor update(s) persisted without a corresponding ChannelManager update.
persister.persist_manager(&*channel_manager)?;
});
Self { stop_thread: stop_thread_clone, thread_handle: Some(handle) }
}
Expand Down

0 comments on commit 4a1f87c

Please sign in to comment.