electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit f84f13529af30a9175f7011dde9bdca96e7f6f8d
parent adbfb2dcc84f015225c63bd239153314bbec05d5
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  3 Mar 2021 22:05:09 +0100

lnhtlc: fix deadlock

Diffstat:
Melectrum/lnhtlc.py | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py @@ -41,7 +41,13 @@ class HTLCManager: if not log[sub]['fee_updates']: log[sub]['fee_updates'][0] = FeeUpdate(rate=initial_feerate, ctn_local=0, ctn_remote=0) self.log = log - self.lock = threading.RLock() + + # We need a lock as many methods of HTLCManager are accessed by both the asyncio thread and the GUI. + # lnchannel sometimes calls us with Channel.db_lock (== log.lock) already taken, + # and we ourselves often take log.lock (via StoredDict.__getitem__). + # Hence, to avoid deadlocks, we reuse this same lock. + self.lock = log.lock + self._init_maybe_active_htlc_ids() def with_lock(func):