mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
happy_eyeballs: don't retain errored connects
This commit is contained in:
parent
7b7f2866fc
commit
8850c95155
2 changed files with 23 additions and 9 deletions
|
@ -80,15 +80,29 @@ impl Future for Connecter {
|
||||||
return Err(format!("{}", e)),
|
return Err(format!("{}", e)),
|
||||||
}
|
}
|
||||||
|
|
||||||
for mut connect in self.connects.values_mut() {
|
let mut connected_stream = None;
|
||||||
match connect.poll() {
|
self.connects.retain(|_, connect| {
|
||||||
Ok(Async::NotReady) => (),
|
if connected_stream.is_some() {
|
||||||
Ok(Async::Ready(tcp_stream)) =>
|
return false;
|
||||||
// Success!
|
|
||||||
return Ok(Async::Ready(tcp_stream)),
|
|
||||||
Err(e) =>
|
|
||||||
println!("{}", e),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match connect.poll() {
|
||||||
|
Ok(Async::NotReady) => true,
|
||||||
|
Ok(Async::Ready(tcp_stream)) => {
|
||||||
|
// Success!
|
||||||
|
connected_stream = Some(tcp_stream);
|
||||||
|
false
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
println!("{}", e);
|
||||||
|
false
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
match connected_stream {
|
||||||
|
Some(tcp_stream) =>
|
||||||
|
return Ok(Async::Ready(tcp_stream)),
|
||||||
|
None => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.lookup.is_none() &&
|
if self.lookup.is_none() &&
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl<S: AsyncRead + AsyncWrite> Future for StreamStart<S> {
|
||||||
} else {
|
} else {
|
||||||
(StreamStartState::RecvFeatures(stream, stream_ns), Ok(Async::NotReady))
|
(StreamStartState::RecvFeatures(stream, stream_ns), Ok(Async::NotReady))
|
||||||
},
|
},
|
||||||
Ok(Async::Ready(item)) =>
|
Ok(Async::Ready(_)) =>
|
||||||
(StreamStartState::RecvFeatures(stream, stream_ns), Ok(Async::NotReady)),
|
(StreamStartState::RecvFeatures(stream, stream_ns), Ok(Async::NotReady)),
|
||||||
Ok(Async::NotReady) =>
|
Ok(Async::NotReady) =>
|
||||||
(StreamStartState::RecvFeatures(stream, stream_ns), Ok(Async::NotReady)),
|
(StreamStartState::RecvFeatures(stream, stream_ns), Ok(Async::NotReady)),
|
||||||
|
|
Loading…
Reference in a new issue