Merge bitcoindevkit/rust-electrum-client#80: Client: Drop script subscriptions to free lock

aa0b957818 Client: Drop script subscriptions to free lock (Sebastian Kung)

Pull request description:

  This fixes a supposed deadlock when the reader thread receives a script subscription notification from the server before it receives a subscribing response.

  I am not 100% sure if this actually fixes a deadlock, but I ran into this in a regtest setup where a bunch of subscriptions were made, while some script notifications could be processed in parallel. My test failed sporadically with the electrum client locking up completely and adding this drop made the tests consistently pass again.

ACKs for top commit:
  afilini:
    ACK aa0b957818, makes a lot of sense!

Tree-SHA512: b1bbea71fb56a189081b9aa602f768ef50d349a6ad6f3a3f64264259954a541fee85cad84461afeafe1ba17e11950c18fdcadb7c47a5fa1b3ce2fa2ac1cdcdc0
This commit is contained in:
Alekos Filini 2022-08-18 11:42:27 +02:00
commit 7e40dfd441
No known key found for this signature in database
GPG Key ID: 431401E4A4530061

View File

@ -827,6 +827,7 @@ impl<T: Read + Write> ElectrumApi for RawClient<T> {
}
script_notifications.insert(script_hash, VecDeque::new());
drop(script_notifications);
let req = Request::new_id(
self.last_id.fetch_add(1, Ordering::SeqCst),