fix(rt): prevent fallback reactor thread from being created accidentally

Switches from `Handle::current()` to `Handle::default()`.
This commit is contained in:
Sean McArthur
2018-12-18 12:44:08 -08:00
parent ce56ffb656
commit 1d253b4d47
3 changed files with 3 additions and 3 deletions

View File

@@ -502,7 +502,7 @@ 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) => Cow::Borrowed(handle),
None => Cow::Owned(Handle::current()), None => Cow::Owned(Handle::default()),
}; };
Ok(TcpStream::connect_std(builder.to_tcp_stream()?, addr, &handle)) Ok(TcpStream::connect_std(builder.to_tcp_stream()?, addr, &handle))

View File

@@ -125,7 +125,7 @@ impl Server<AddrIncoming, ()> {
/// Create a new instance from a `std::net::TcpListener` instance. /// Create a new instance from a `std::net::TcpListener` instance.
pub fn from_tcp(listener: StdTcpListener) -> Result<Builder<AddrIncoming>, ::Error> { pub fn from_tcp(listener: StdTcpListener) -> Result<Builder<AddrIncoming>, ::Error> {
let handle = tokio_reactor::Handle::current(); let handle = tokio_reactor::Handle::default();
AddrIncoming::from_std(listener, &handle) AddrIncoming::from_std(listener, &handle)
.map(Server::builder) .map(Server::builder)
} }

View File

@@ -29,7 +29,7 @@ impl AddrIncoming {
if let Some(handle) = handle { if let Some(handle) = handle {
AddrIncoming::from_std(std_listener, handle) AddrIncoming::from_std(std_listener, handle)
} else { } else {
let handle = Handle::current(); let handle = Handle::default();
AddrIncoming::from_std(std_listener, &handle) AddrIncoming::from_std(std_listener, &handle)
} }
} }