Process messages with only the top-level read lock held
authorMatt Corallo <git@bluematt.me>
Wed, 6 Oct 2021 06:58:15 +0000 (06:58 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 10 May 2022 23:40:20 +0000 (23:40 +0000)
commita731efcb6822609b400170bce54d59addc5821c3
tree3fab1b1ebb77ee0a31d8ab3dfa041954a1ec4abf
parent7c8b0986984e0882229c239ef2d3b621a61f7d35
Process messages with only the top-level read lock held

Users are required to only ever call `read_event` serially
per-peer, thus we actually don't need any locks while we're
processing messages - we can only be processing messages in one
thread per-peer.

That said, we do need to ensure that another thread doesn't
disconnect the peer we're processing messages for, as that could
result in a peer_disconencted call while we're processing a
message for the same peer - somewhat nonsensical.

This significantly improves parallelism especially during gossip
processing as it avoids waiting on the entire set of individual
peer locks to forward a gossip message while several other threads
are validating gossip messages with their individual peer locks
held.
lightning/src/ln/peer_handler.rs