Skip to content

Commit

Permalink
fix: now it's safe to call BroadcastAcceptor::stop twice
Browse files Browse the repository at this point in the history
`std::net::addr::SocketAddr::recv_from` is used to wait for the other
thread to finish cleanly. The problem is that the `crust_peer` example
calls `ConnectionManager::stop` twice and `BroadcastAcceptor::stop`
doesn't handle "double stop correctly".

This commit avoids unnecessary and buggy calls to
`beacon::BroadcastAcceptor::stop`.

Fixes maidsafe-archive#141
  • Loading branch information
vinipsmaker committed Jun 22, 2015
1 parent ca7a188 commit 0213682
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ impl ConnectionManager {

/// This should be called before destroying an instance of a ConnectionManager to allow the
/// listener threads to join. Once called, the ConnectionManager should be destroyed.
pub fn stop(&self) {
pub fn stop(&mut self) {
if let Some(beacon_guid_and_port) = self.beacon_guid_and_port {
beacon::BroadcastAcceptor::stop(&beacon_guid_and_port)
beacon::BroadcastAcceptor::stop(&beacon_guid_and_port);
self.beacon_guid_and_port = None;
}
let mut listening_ports = Vec::<Port>::new();
let weak_state = self.state.downgrade();
Expand Down

0 comments on commit 0213682

Please sign in to comment.