From d08e1208d1485cc6fad36b9efcf19d6e29c78b4a Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Tue, 6 Aug 2019 15:17:49 +0300 Subject: [PATCH 1/2] fix(server): worked-around deprecation of `poll_accept` method in tokio This fixes building with the tokio master branch head. Refactoring will be required to actually use the new `accept` async fn. --- examples/send_file.rs | 2 +- src/server/tcp.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/send_file.rs b/examples/send_file.rs index c9ca15cd55..3a12f7ac10 100644 --- a/examples/send_file.rs +++ b/examples/send_file.rs @@ -2,7 +2,7 @@ #![deny(warnings)] use tokio::io::AsyncReadExt; -use tokio_fs::file::File; +use tokio_fs::File; use hyper::{Body, Method, Result, Request, Response, Server, StatusCode}; use hyper::service::{make_service_fn, service_fn}; diff --git a/src/server/tcp.rs b/src/server/tcp.rs index f566233649..ef64726b53 100644 --- a/src/server/tcp.rs +++ b/src/server/tcp.rs @@ -4,6 +4,7 @@ use std::net::{SocketAddr, TcpListener as StdTcpListener}; use std::time::{Duration, Instant}; use futures_core::Stream; +use futures_util::FutureExt as _; use tokio_reactor::Handle; use tokio_tcp::TcpListener; use tokio_timer::Delay; @@ -105,8 +106,10 @@ impl AddrIncoming { } self.timeout = None; + let mut accept_fut = self.listener.accept().boxed(); + loop { - match Pin::new(&mut self.listener).poll_accept(cx) { + match accept_fut.poll_unpin(cx) { Poll::Ready(Ok((socket, addr))) => { if let Some(dur) = self.tcp_keepalive_timeout { if let Err(e) = socket.set_keepalive(Some(dur)) { From d79e9c6a5ebe7b131791b66c471930fc222bdd5b Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Fri, 9 Aug 2019 14:05:30 +0300 Subject: [PATCH 2/2] fix(common): worked-around deprecation of `poll_ref` method in tokio --- src/common/drain.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/drain.rs b/src/common/drain.rs index f6a250c368..6ce6da6bf3 100644 --- a/src/common/drain.rs +++ b/src/common/drain.rs @@ -3,6 +3,7 @@ use std::mem; use tokio_sync::{mpsc, watch}; use super::{Future, Never, Poll, Pin, task}; +use futures_util::FutureExt as _; // Sentinel value signaling that the watch is still open enum Action { @@ -99,7 +100,9 @@ where loop { match mem::replace(&mut me.state, State::Draining) { State::Watch(on_drain) => { - match me.watch.rx.poll_ref(cx) { + let mut recv_fut = me.watch.rx.recv_ref().boxed(); + + match recv_fut.poll_unpin(cx) { Poll::Ready(None) => { // Drain has been triggered! on_drain(unsafe { Pin::new_unchecked(&mut me.future) });