From fe84eb4ff65b843cf0f56e1d4b038574ce144e53 Mon Sep 17 00:00:00 2001 From: arkpar Date: Sun, 21 Feb 2016 13:58:01 +0100 Subject: [PATCH] Fix locking --- util/src/network/host.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/src/network/host.rs b/util/src/network/host.rs index feddf1952..70915bee3 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -777,7 +777,8 @@ impl IoHandler> for Host where Messa FIRST_SESSION ... LAST_SESSION => self.session_readable(stream, io), FIRST_HANDSHAKE ... LAST_HANDSHAKE => self.handshake_readable(stream, io), DISCOVERY => { - if let Some(node_changes) = self.discovery.as_ref().unwrap().lock().unwrap().readable() { + let node_changes = { self.discovery.as_ref().unwrap().lock().unwrap().readable() }; + if let Some(node_changes) = node_changes { self.update_nodes(io, node_changes); } io.update_registration(DISCOVERY).expect("Error updating discovery registration"); @@ -809,7 +810,8 @@ impl IoHandler> for Host where Messa io.update_registration(DISCOVERY).expect("Error updating discovery registration"); }, DISCOVERY_ROUND => { - if let Some(node_changes) = self.discovery.as_ref().unwrap().lock().unwrap().round() { + let node_changes = { self.discovery.as_ref().unwrap().lock().unwrap().round() }; + if let Some(node_changes) = node_changes { self.update_nodes(io, node_changes); } io.update_registration(DISCOVERY).expect("Error updating discovery registration");