From 156d42ab801d32068cce238ddb79038d3c3a4b41 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 27 Jul 2022 20:35:13 +0100 Subject: [PATCH] chanmgr: Postpone padding parameters computation Now that we make an extract from the incoming NetDir, we can move the padding parameters computation to after we take the lock. This will be necessary for it to be able to depend on the config and dormancy, records of which are protected by the chanmgr lock. --- crates/tor-chanmgr/src/mgr/map.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/tor-chanmgr/src/mgr/map.rs b/crates/tor-chanmgr/src/mgr/map.rs index 2b3ebb50e..295e7fac6 100644 --- a/crates/tor-chanmgr/src/mgr/map.rs +++ b/crates/tor-chanmgr/src/mgr/map.rs @@ -344,6 +344,18 @@ impl ChannelMap { nde }; + let mut inner = self + .inner + .lock() + .map_err(|_| internal!("poisonned channel manager"))?; + + if let Some(new_config) = new_config { + inner.config = new_config.clone(); + } + if let Some(new_dormancy) = new_dormancy { + inner.dormancy = new_dormancy; + } + let padding_parameters = { let mut p = PaddingParametersBuilder::default(); update_padding_parameters_from_netdir(&mut p, &netdir).unwrap_or_else(|e| { @@ -359,18 +371,6 @@ impl ChannelMap { p }; - let mut inner = self - .inner - .lock() - .map_err(|_| internal!("poisonned channel manager"))?; - - if let Some(new_config) = new_config { - inner.config = new_config.clone(); - } - if let Some(new_dormancy) = new_dormancy { - inner.dormancy = new_dormancy; - } - let update = inner .channels_params .start_update()