Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): worked-around deprecation of poll_accept method in tokio #1890

Merged
merged 2 commits into from
Aug 14, 2019
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
2 changes: 1 addition & 1 deletion examples/send_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
5 changes: 4 additions & 1 deletion src/common/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) });
Expand Down
5 changes: 4 additions & 1 deletion src/server/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down