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

Fixed potential deadlock on startup #592

merged 1 commit into from Mar 4, 2016

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Mar 4, 2016

No description provided.

@arkpar arkpar added the A0-pleasereview 🤓 Pull request needs code review. label Mar 4, 2016
@@ -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

@NikVolf NikVolf added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 4, 2016
gavofyork pushed a commit that referenced this pull request Mar 4, 2016
Fixed potential deadlock on startup
@gavofyork gavofyork merged commit 8ed632e into master Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants