Skip to content

Commit 18a18d8

Browse files
committed
Correct lock drop'ing in ChainMonitor::update_channel
e21a500 cleaned up the error handling in `ChainMonitor::update_channel` a bit, but accidentally replaced the deliberate panic with a hang. This commit ensures we properly drop the monitors read lock before taking a write lock.
1 parent ab93d35 commit 18a18d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightning/src/chain/chainmonitor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,7 @@ where C::Target: chain::Filter,
753753

754754
fn update_channel(&self, funding_txo: OutPoint, update: &ChannelMonitorUpdate) -> ChannelMonitorUpdateStatus {
755755
// Update the monitor that watches the channel referred to by the given outpoint.
756-
let monitors_lock = self.monitors.read().unwrap();
757-
let monitors = monitors_lock.deref();
756+
let monitors = self.monitors.read().unwrap();
758757
match monitors.get(&funding_txo) {
759758
None => {
760759
log_error!(self.logger, "Failed to update channel monitor: no such monitor registered");
@@ -797,6 +796,7 @@ where C::Target: chain::Filter,
797796
ChannelMonitorUpdateStatus::UnrecoverableError => {
798797
// Take the monitors lock for writing so that we poison it and any future
799798
// operations going forward fail immediately.
799+
core::mem::drop(pending_monitor_updates);
800800
core::mem::drop(monitors);
801801
let _poison = self.monitors.write().unwrap();
802802
let err_str = "ChannelMonitor[Update] persistence failed unrecoverably. This indicates we cannot continue normal operation and must shut down.";

0 commit comments

Comments
 (0)