@@ -697,7 +697,12 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
697
697
/// expose them to users via a PaymentReceived event. HTLCs which do not meet the requirements
698
698
/// here are failed when we process them as pending-forwardable-HTLCs, and entries are removed
699
699
/// after we generate a PaymentReceived upon receipt of all MPP parts or when they time out.
700
- /// Locked *after* channel_state.
700
+ ///
701
+ /// If any of these locks are held at the same time as `pending_inbound_payments`, the lock
702
+ /// order requires that these locks are taken prior to `pending_inbound_payments`:
703
+ /// * `channel_state`
704
+ /// * `forward_htlcs`
705
+ /// * `per_peer_state`
701
706
pending_inbound_payments : Mutex < HashMap < PaymentHash , PendingInboundPayment > > ,
702
707
703
708
/// The session_priv bytes and retry metadata of outbound payments which are pending resolution.
@@ -711,7 +716,12 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
711
716
///
712
717
/// See `PendingOutboundPayment` documentation for more info.
713
718
///
714
- /// Locked *after* channel_state.
719
+ /// If any of these locks are held at the same time as `pending_outbound_payments`, the lock
720
+ /// order requires that these locks are taken prior to `pending_outbound_payments`:
721
+ /// * `channel_state`
722
+ /// * `forward_htlcs`
723
+ /// * `per_peer_state`
724
+ /// * `pending_inbound_payments`
715
725
pending_outbound_payments : Mutex < HashMap < PaymentId , PendingOutboundPayment > > ,
716
726
717
727
/// SCID/SCID Alias -> forward infos. Key of 0 means payments received.
@@ -722,6 +732,8 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
722
732
///
723
733
/// Note that no consistency guarantees are made about the existence of a channel with the
724
734
/// `short_channel_id` here, nor the `short_channel_id` in the `PendingHTLCInfo`!
735
+ ///
736
+ /// If also holding `channel_state` lock, must lock `channel_state` prior to `forward_htlcs`.
725
737
#[ cfg( any( test, feature = "_test_utils" ) ) ]
726
738
pub ( super ) forward_htlcs : Mutex < HashMap < u64 , Vec < HTLCForwardInfo > > > ,
727
739
#[ cfg( not( any( test, feature = "_test_utils" ) ) ) ]
@@ -785,10 +797,28 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
785
797
/// operate on the inner value freely. Sadly, this prevents parallel operation when opening a
786
798
/// new channel.
787
799
///
788
- /// If also holding `channel_state` lock, must lock `channel_state` prior to `per_peer_state`.
800
+ /// If any of these locks are held at the same time as `per_peer_state`, the lock order
801
+ /// requires that these locks are taken prior to `per_peer_state`:
802
+ /// * `channel_state`
803
+ /// * `forward_htlcs`
789
804
per_peer_state : RwLock < HashMap < PublicKey , Mutex < PeerState > > > ,
790
805
806
+ /// If any of these locks are held at the same time as `pending_events`, the lock order
807
+ /// requires that these locks are taken prior to `pending_events`:
808
+ /// * `channel_state`
809
+ /// * `forward_htlcs`
810
+ /// * `per_peer_state`
811
+ /// * `pending_inbound_payments`
812
+ /// * `pending_outbound_payments`
791
813
pending_events : Mutex < Vec < events:: Event > > ,
814
+ /// If any of these locks are held at the same time as `pending_background_events`, the lock
815
+ /// order requires that these locks are taken prior to `pending_background_events`:
816
+ /// * `channel_state`
817
+ /// * `forward_htlcs`
818
+ /// * `per_peer_state`
819
+ /// * `pending_inbound_payments`
820
+ /// * `pending_outbound_payments`
821
+ /// * `pending_events`
792
822
pending_background_events : Mutex < Vec < BackgroundEvent > > ,
793
823
/// Used when we have to take a BIG lock to make sure everything is self-consistent.
794
824
/// Essentially just when we're serializing ourselves out.
0 commit comments