Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): join on thread when Listening drops #458

Merged
merged 1 commit into from
Apr 15, 2015
Merged

Conversation

seanmonstar
Copy link
Member

Closes #447

}
}
}

impl Listening {
/// Stop the server from listening to its socket address.
pub fn close(&mut self) -> HttpResult<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function should probably take the guard for now, so that it at least lets you close a program running a server.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah right

@seanmonstar
Copy link
Member Author

updated

/// The socket addresses that the server is bound to.
pub socket: SocketAddr,
}

impl Drop for Listening {
fn drop(&mut self) {
match self._guard.take() {
Copy link
Contributor

Choose a reason for hiding this comment

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

much shorter to just write self._guard.take().map(|g| let _ = g.join());

@seanmonstar
Copy link
Member Author

updated again

reem added a commit that referenced this pull request Apr 15, 2015
fix(server): join on thread when Listening drops
@reem reem merged commit dac2f4d into master Apr 15, 2015
@reem reem deleted the server-spawn branch April 15, 2015 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Main thread shouldn't panic when child threads panic
2 participants