Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/client/legacy/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::future::Future;
use std::io;
use std::marker::PhantomData;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use std::pin::Pin;
use std::pin::{Pin, pin};
use std::sync::Arc;
use std::task::{self, Poll, ready};
use std::time::Duration;
Expand Down Expand Up @@ -949,14 +949,9 @@ impl ConnectingTcp<'_> {
match self.fallback {
None => self.preferred.connect(self.config).await,
Some(mut fallback) => {
let preferred_fut = self.preferred.connect(self.config);
futures_util::pin_mut!(preferred_fut);

let fallback_fut = fallback.remote.connect(self.config);
futures_util::pin_mut!(fallback_fut);

let fallback_delay = fallback.delay;
futures_util::pin_mut!(fallback_delay);
let preferred_fut = pin!(self.preferred.connect(self.config));
let fallback_fut = pin!(fallback.remote.connect(self.config));
let fallback_delay = pin!(fallback.delay);

let (result, future) =
match futures_util::future::select(preferred_fut, fallback_delay).await {
Expand Down
20 changes: 7 additions & 13 deletions tests/legacy_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod test_utils;

use std::io::{Read, Write};
use std::net::{SocketAddr, TcpListener};
use std::pin::Pin;
use std::pin::{Pin, pin};
use std::sync::Arc;
use std::sync::atomic::Ordering;
use std::task::Poll;
Expand Down Expand Up @@ -146,8 +146,7 @@ async fn drop_client_closes_idle_connections() {
drop(client);

// and wait a few ticks for the connections to close
let t = tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out"));
futures_util::pin_mut!(t);
let t = pin!(tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out")));
let close = closes.into_future().map(|(opt, _)| opt.expect("closes"));
future::select(t, close).await;
t1.await.unwrap();
Expand Down Expand Up @@ -197,8 +196,7 @@ async fn drop_response_future_closes_in_progress_connection() {
future::select(res, rx1).await;

// res now dropped
let t = tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out"));
futures_util::pin_mut!(t);
let t = pin!(tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out")));
let close = closes.into_future().map(|(opt, _)| opt.expect("closes"));
future::select(t, close).await;
}
Expand Down Expand Up @@ -254,8 +252,7 @@ async fn drop_response_body_closes_in_progress_connection() {
res.unwrap();

// and wait a few ticks to see the connection drop
let t = tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out"));
futures_util::pin_mut!(t);
let t = pin!(tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out")));
let close = closes.into_future().map(|(opt, _)| opt.expect("closes"));
future::select(t, close).await;
}
Expand Down Expand Up @@ -308,8 +305,7 @@ async fn no_keep_alive_closes_connection() {
let (res, _) = future::join(res, rx).await;
res.unwrap();

let t = tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out"));
futures_util::pin_mut!(t);
let t = pin!(tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out")));
let close = closes.into_future().map(|(opt, _)| opt.expect("closes"));
future::select(close, t).await;
}
Expand Down Expand Up @@ -356,8 +352,7 @@ async fn socket_disconnect_closes_idle_conn() {
let (res, _) = future::join(res, rx).await;
res.unwrap();

let t = tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out"));
futures_util::pin_mut!(t);
let t = pin!(tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out")));
let close = closes.into_future().map(|(opt, _)| opt.expect("closes"));
future::select(t, close).await;
}
Expand Down Expand Up @@ -581,8 +576,7 @@ async fn client_keep_alive_when_response_before_request_body_ends() {
assert_eq!(connects.load(Ordering::Relaxed), 1);

drop(client);
let t = tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out"));
futures_util::pin_mut!(t);
let t = pin!(tokio::time::sleep(Duration::from_millis(100)).map(|_| panic!("time out")));
let close = closes.into_future().map(|(opt, _)| opt.expect("closes"));
future::select(t, close).await;
}
Expand Down
Loading