Fix deadlock in handle_error!() when we have HTLCs to fail-back.
authorMatt Corallo <git@bluematt.me>
Mon, 13 Jan 2020 21:10:30 +0000 (16:10 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 1 Apr 2020 23:27:22 +0000 (16:27 -0700)
commit86143fd69ddf88a03fc19244aca33ec598ee1720
tree6d71be73b8358a11091fb13a14866a5379cb5004
parent8bd155e77482273c8b6e278f8282dc267144a8a7
Fix deadlock in handle_error!() when we have HTLCs to fail-back.

This partially reverts 933ae3470309f21ef7537ffbcdc42070d60e1e74,
though note that 933ae3470309f21ef7537ffbcdc42070d60e1e74 fixed a
similar deadlock while introducing this one.

If we have HTLCs to fail backwards, handle_error!() will call
finish_force_close_channel() which will attempt to lock channel_state
while it is locked at the original caller. Instead, hold the lock for
shorter scopes such that it is not held upon entering handle_error!().

Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
lightning/src/ln/channelmanager.rs