diff --git a/crates/tor-dirmgr/src/lib.rs b/crates/tor-dirmgr/src/lib.rs index 20ac7f367..1c5364666 100644 --- a/crates/tor-dirmgr/src/lib.rs +++ b/crates/tor-dirmgr/src/lib.rs @@ -376,11 +376,14 @@ impl DirMgr { v.store(false, Ordering::SeqCst); }); - let schedule = match self.task_schedule.lock().expect("poisoned lock").take() { - Some(sched) => sched, - None => { - debug!("Attempted to bootstrap twice; ignoring."); - return Ok(()); + let schedule = { + let sched = self.task_schedule.lock().expect("poisoned lock").take(); + match sched { + Some(sched) => sched, + None => { + debug!("Attempted to bootstrap twice; ignoring."); + return Ok(()); + } } }; diff --git a/crates/tor-dirmgr/src/shared_ref.rs b/crates/tor-dirmgr/src/shared_ref.rs index d1b83b9b2..7c0e43963 100644 --- a/crates/tor-dirmgr/src/shared_ref.rs +++ b/crates/tor-dirmgr/src/shared_ref.rs @@ -79,12 +79,12 @@ impl SharedMutArc { F: FnOnce(&mut T) -> Result, T: Clone, { - match self + let mut writeable = self .dir .write() - .expect("Poisoned lock for directory reference") - .as_mut() - { + .expect("Poisoned lock for directory reference"); + let dir = writeable.as_mut(); + match dir { None => Err(Error::DirectoryNotPresent), // Kinda bogus. Some(arc) => func(Arc::make_mut(arc)), } diff --git a/crates/tor-guardmgr/src/lib.rs b/crates/tor-guardmgr/src/lib.rs index 48f76b45c..4898825f5 100644 --- a/crates/tor-guardmgr/src/lib.rs +++ b/crates/tor-guardmgr/src/lib.rs @@ -591,8 +591,8 @@ impl GuardMgr { ) { let now = self.runtime.now(); let mut inner = self.inner.lock().expect("Poisoned lock"); - - for id in inner.lookup_ids(ed_identity, rsa_identity) { + let ids = inner.lookup_ids(ed_identity, rsa_identity); + for id in ids { match &id.0 { FirstHopIdInner::Guard(id) => { inner.guards.active_guards_mut().record_failure( diff --git a/crates/tor-persist/src/testing.rs b/crates/tor-persist/src/testing.rs index e1045e9e3..01f264302 100644 --- a/crates/tor-persist/src/testing.rs +++ b/crates/tor-persist/src/testing.rs @@ -96,7 +96,8 @@ impl StateMgr for TestingStateMgr { { let inner = self.inner.lock().expect("Lock poisoned."); let storage = inner.storage.lock().expect("Lock poisoned."); - match storage.entries.get(key) { + let content = storage.entries.get(key); + match content { Some(value) => Ok(Some(serde_json::from_str(value).map_err(load_error)?)), None => Ok(None), }