Skip to content

Commit ce82a33

Browse files
committed
Persist ChannelManager before BackgroundProcessor exits
Fixes #1237.
1 parent 7b6a7bb commit ce82a33

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
@@ -232,7 +232,7 @@ impl BackgroundProcessor {
232232
// Exit the loop if the background processor was requested to stop.
233233
if stop_thread.load(Ordering::Acquire) == true {
234234
log_trace!(logger, "Terminating background processor.");
235-
return Ok(());
235+
break;
236236
}
237237
if last_freshness_call.elapsed().as_secs() > FRESHNESS_TIMER {
238238
log_trace!(logger, "Calling ChannelManager's timer_tick_occurred");
@@ -269,6 +269,10 @@ impl BackgroundProcessor {
269269
}
270270
}
271271
}
272+
// After we exit, ensure we persist the ChannelManager one final time - this avoids
273+
// some races where users quit while channel updates were in-flight, with
274+
// ChannelMonitor update(s) persisted without a corresponding ChannelManager update.
275+
persister.persist_manager(&*channel_manager)
272276
});
273277
Self { stop_thread: stop_thread_clone, thread_handle: Some(handle) }
274278
}

0 commit comments

Comments
 (0)