Skip to content

Commit

Permalink
Merge f7e8c6f into 6eac3dc
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Hutchison committed May 8, 2015
2 parents 6eac3dc + f7e8c6f commit 77eb3a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
16 changes: 6 additions & 10 deletions src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,12 @@ impl ConnectionManager {
let is_broadcast_acceptor = self.beacon_guid.is_some();
let _ = thread::spawn(move || {
for endpoint in &endpoints {
for itr in listening.iter() {
let unconnected: bool =
lock_state(&ws, |state| Ok(state.connections.is_empty())).unwrap_or(false);
if unconnected || itr.is_master(endpoint) {
let ws = ws.clone();
let result = transport::connect(endpoint.clone())
.and_then(|trans| handle_connect(ws, trans,
is_broadcast_acceptor));
if result.is_ok() { return; }
}
for _ in listening.iter() {
let ws = ws.clone();
let result = transport::connect(endpoint.clone())
.and_then(|trans| handle_connect(ws, trans,
is_broadcast_acceptor));
if result.is_ok() { return; }
}
}
});
Expand Down
18 changes: 0 additions & 18 deletions src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,6 @@ impl Endpoint {
Endpoint::Tcp(address) => address,
}
}

/// Returns whether this endpoint should be chosen over `other` when deciding to connect.
pub fn is_master(&self, other: &Endpoint) -> bool {
match *self {
Endpoint::Tcp(my_address) => {
match *other {
Endpoint::Tcp(other_address) => {
if my_address.port() == other_address.port() {
return my_address.ip() < other_address.ip();
} else {
return my_address.port() < other_address.port();
}
}
}
}
}
return true;
}
}

impl Encodable for Endpoint {
Expand Down

0 comments on commit 77eb3a5

Please sign in to comment.