Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fixed potential deadlock on startup #592

Merged
merged 1 commit into from
Mar 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion util/src/network/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
// public_endpoint in host info contains local adderss at this point
let listen_address = self.info.read().unwrap().public_endpoint.address.clone();
let udp_port = self.info.read().unwrap().config.udp_port.unwrap_or(listen_address.port());
let public_endpoint = match self.info.read().unwrap().config.public_address {
let public_address = self.info.read().unwrap().config.public_address.clone();
let public_endpoint = match public_address {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here self.info was not released till the end of the match expression. If there is another attempt to write-lock it between here and line 408 there would be a deadlock

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be placed on a single line with:

let public_endpoint = match {self.info.read().unwrap().config.public_address.clone()} {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly this does not work.
http://is.gd/1Pf3kO

None => {
let public_address = select_public_address(listen_address.port());
let local_endpoint = NodeEndpoint { address: public_address, udp_port: udp_port };
Expand Down