refactor(lib): update to tokio alpha.4
This commit is contained in:
		
							
								
								
									
										16
									
								
								Cargo.toml
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Cargo.toml
									
									
									
									
									
								
							| @@ -36,13 +36,13 @@ log = "0.4" | |||||||
| net2 = { version = "0.2.32", optional = true } | net2 = { version = "0.2.32", optional = true } | ||||||
| pin-utils = "=0.1.0-alpha.4" | pin-utils = "=0.1.0-alpha.4" | ||||||
| time = "0.1" | time = "0.1" | ||||||
| tokio = { version = "=0.2.0-alpha.2", optional = true, default-features = false, features = ["rt-full"] } | tokio = { version = "=0.2.0-alpha.4", optional = true, default-features = false, features = ["rt-full"] } | ||||||
| tower-service = "=0.3.0-alpha.1" | tower-service = "=0.3.0-alpha.1" | ||||||
| tokio-executor = "=0.2.0-alpha.2" | tokio-executor = "=0.2.0-alpha.4" | ||||||
| tokio-io = "=0.2.0-alpha.2" | tokio-io = "=0.2.0-alpha.4" | ||||||
| tokio-sync = "=0.2.0-alpha.2" | tokio-sync = "=0.2.0-alpha.4" | ||||||
| tokio-net = { version = "=0.2.0-alpha.2", optional = true, features = ["tcp"] } | tokio-net = { version = "=0.2.0-alpha.4", optional = true, features = ["tcp"] } | ||||||
| tokio-timer = { version = "=0.3.0-alpha.2", optional = true } | tokio-timer = { version = "=0.3.0-alpha.4", optional = true } | ||||||
| want = "0.3" | want = "0.3" | ||||||
|  |  | ||||||
| [dev-dependencies] | [dev-dependencies] | ||||||
| @@ -53,8 +53,8 @@ spmc = "0.3" | |||||||
| serde = "1.0" | serde = "1.0" | ||||||
| serde_derive = "1.0" | serde_derive = "1.0" | ||||||
| serde_json = "1.0" | serde_json = "1.0" | ||||||
| tokio-fs = "0.2.0-alpha.2" | tokio-fs = "0.2.0-alpha.3" | ||||||
| tokio-test = "0.2.0-alpha.2" | tokio-test = "0.2.0-alpha.3" | ||||||
| url = "1.0" | url = "1.0" | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,15 +1,14 @@ | |||||||
| use std::borrow::Cow; |  | ||||||
| use std::fmt; | use std::fmt; | ||||||
| use std::error::Error as StdError; | use std::error::Error as StdError; | ||||||
| use std::io; | use std::io; | ||||||
| use std::mem; | use std::mem; | ||||||
| use std::net::{IpAddr, SocketAddr}; | use std::net::{IpAddr, SocketAddr}; | ||||||
| use std::time::{Duration, Instant}; | use std::time::Duration; | ||||||
|  |  | ||||||
| use http::uri::Scheme; | use http::uri::Scheme; | ||||||
| use net2::TcpBuilder; | use net2::TcpBuilder; | ||||||
| use tokio_net::driver::Handle; | use tokio_net::driver::Handle; | ||||||
| use tokio_net::tcp::{TcpStream/*, ConnectFuture*/}; | use tokio_net::tcp::TcpStream; | ||||||
| use tokio_timer::Delay; | use tokio_timer::Delay; | ||||||
|  |  | ||||||
| use crate::common::{Future, Pin, Poll, task}; | use crate::common::{Future, Pin, Poll, task}; | ||||||
| @@ -416,7 +415,7 @@ impl ConnectingTcp { | |||||||
|                 local_addr, |                 local_addr, | ||||||
|                 preferred: ConnectingTcpRemote::new(preferred_addrs), |                 preferred: ConnectingTcpRemote::new(preferred_addrs), | ||||||
|                 fallback: Some(ConnectingTcpFallback { |                 fallback: Some(ConnectingTcpFallback { | ||||||
|                     delay: Delay::new(Instant::now() + fallback_timeout), |                     delay: tokio_timer::sleep(fallback_timeout), | ||||||
|                     remote: ConnectingTcpRemote::new(fallback_addrs), |                     remote: ConnectingTcpRemote::new(fallback_addrs), | ||||||
|                 }), |                 }), | ||||||
|                 reuse_address, |                 reuse_address, | ||||||
| @@ -503,8 +502,7 @@ fn connect(addr: &SocketAddr, local_addr: &Option<IpAddr>, handle: &Option<Handl | |||||||
|     if let Some(ref local_addr) = *local_addr { |     if let Some(ref local_addr) = *local_addr { | ||||||
|         // Caller has requested this socket be bound before calling connect |         // Caller has requested this socket be bound before calling connect | ||||||
|         builder.bind(SocketAddr::new(local_addr.clone(), 0))?; |         builder.bind(SocketAddr::new(local_addr.clone(), 0))?; | ||||||
|     } |     } else if cfg!(windows) { | ||||||
|     else if cfg!(windows) { |  | ||||||
|         // Windows requires a socket be bound before calling connect |         // Windows requires a socket be bound before calling connect | ||||||
|         let any: SocketAddr = match addr { |         let any: SocketAddr = match addr { | ||||||
|             &SocketAddr::V4(_) => { |             &SocketAddr::V4(_) => { | ||||||
| @@ -518,11 +516,18 @@ fn connect(addr: &SocketAddr, local_addr: &Option<IpAddr>, handle: &Option<Handl | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     let handle = match *handle { |     let handle = match *handle { | ||||||
|         Some(ref handle) => Cow::Borrowed(handle), |         Some(ref handle) => handle.clone(), | ||||||
|         None => Cow::Owned(Handle::default()), |         None => Handle::default(), | ||||||
|     }; |     }; | ||||||
|  |     let addr = *addr; | ||||||
|  |  | ||||||
|     Ok(Box::pin(TcpStream::connect_std(builder.to_tcp_stream()?, addr, &handle))) |     let std_tcp = builder.to_tcp_stream()?; | ||||||
|  |  | ||||||
|  |     Ok(Box::pin(async move { | ||||||
|  |         TcpStream::connect_std(std_tcp, &addr, &handle).await | ||||||
|  |     })) | ||||||
|  |  | ||||||
|  |     //Ok(Box::pin(TcpStream::connect_std(std_tcp, addr, &handle))) | ||||||
| } | } | ||||||
|  |  | ||||||
| impl ConnectingTcp { | impl ConnectingTcp { | ||||||
|   | |||||||
| @@ -134,8 +134,7 @@ impl AddrIncoming { | |||||||
|                         error!("accept error: {}", e); |                         error!("accept error: {}", e); | ||||||
|  |  | ||||||
|                         // Sleep 1s. |                         // Sleep 1s. | ||||||
|                         let delay = Instant::now() + Duration::from_secs(1); |                         let mut timeout = tokio_timer::sleep(Duration::from_secs(1)); | ||||||
|                         let mut timeout = Delay::new(delay); |  | ||||||
|  |  | ||||||
|                         match Pin::new(&mut timeout).poll(cx) { |                         match Pin::new(&mut timeout).poll(cx) { | ||||||
|                             Poll::Ready(()) => { |                             Poll::Ready(()) => { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user