Skip to content

Commit 07776d3

Browse files
Merge pull request #1253 from TheBlueMatt/2022-01-background-persist-exit
Persist `ChannelManager` before `BackgroundProcessor` exits
2 parents 19fdde2 + ce82a33 commit 07776d3

File tree

1 file changed

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

1 file changed

+5
-1
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl BackgroundProcessor {
238238
// Exit the loop if the background processor was requested to stop.
239239
if stop_thread.load(Ordering::Acquire) == true {
240240
log_trace!(logger, "Terminating background processor.");
241-
return Ok(());
241+
break;
242242
}
243243
if last_freshness_call.elapsed().as_secs() > FRESHNESS_TIMER {
244244
log_trace!(logger, "Calling ChannelManager's timer_tick_occurred");
@@ -280,6 +280,10 @@ impl BackgroundProcessor {
280280
}
281281
}
282282
}
283+
// After we exit, ensure we persist the ChannelManager one final time - this avoids
284+
// some races where users quit while channel updates were in-flight, with
285+
// ChannelMonitor update(s) persisted without a corresponding ChannelManager update.
286+
persister.persist_manager(&*channel_manager)
283287
});
284288
Self { stop_thread: stop_thread_clone, thread_handle: Some(handle) }
285289
}

0 commit comments

Comments
 (0)