Merge pull request #484 from ethcore/discovery

Fix potential deadlock on node table update
This commit is contained in:
Gav Wood 2016-02-21 15:11:13 +01:00
commit 8b692e6d9d

View File

@ -777,7 +777,8 @@ impl<Message> IoHandler<NetworkIoMessage<Message>> for Host<Message> 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<Message> IoHandler<NetworkIoMessage<Message>> for Host<Message> 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");