From: Matt Corallo Date: Wed, 18 Oct 2023 15:22:26 +0000 (+0000) Subject: Fix race between outbound messages and peer disconnection X-Git-Tag: v0.0.118~12^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=4366369ef5ed9de7a01783bddb97732c6a1eea5f;p=rust-lightning Fix race between outbound messages and peer disconnection Previously, outbound messages held in `process_events` could race with peer disconnection, allowing a message intended for a peer before disconnection to be sent to the same peer after disconnection. The fix is simple - hold the peers read lock while we fetch pending messages from peers (as we disconnect with the write lock). --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 933e7ee6..8e91023b 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1870,15 +1870,13 @@ impl {