]> git.bitcoin.ninja Git - rust-lightning/commit
Hold ChannelManager locks independently
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 5 Mar 2021 20:37:50 +0000 (12:37 -0800)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 5 Mar 2021 23:45:13 +0000 (15:45 -0800)
commit035dda67080431f460c18bd1087e511c0ab778ec
treebae6531e0d62c1eb17af76c9fff2672b498719aa
parentd21d8b3463505f559d6b7cd38159ec9ef8f59ae5
Hold ChannelManager locks independently

ChannelManager reads channel_state and last_block_hash while processing
funding_created and funding_signed messages. It writes these while
processing block_connected and block_disconnected events. To avoid any
potential deadlocks, have each site hold these locks independent of one
another and in a consistent order.

Additionally, use a RwLock instead of Mutex for last_block_hash since
exclusive access is not needed in funding_created / funding_signed and
cannot be guaranteed in block_connected / block_disconnected because of
the reads in the former.
lightning/src/ln/channelmanager.rs