From dd723d14d1e86164cdbc1bc9e4ccd15799159f27 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Fri, 26 Mar 2021 21:41:29 +0800 Subject: [PATCH] use futures_util::future::ready instead of async block for pipeline factory. --- actix-http/src/h1/service.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index 9f528da03..4fe79736b 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -7,6 +7,7 @@ use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_rt::net::TcpStream; use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory}; use futures_core::{future::LocalBoxFuture, ready}; +use futures_util::future::ready; use crate::body::MessageBody; use crate::config::ServiceConfig; @@ -81,9 +82,9 @@ where Error = DispatchError, InitError = (), > { - pipeline_factory(|io: TcpStream| async { + pipeline_factory(|io: TcpStream| { let peer_addr = io.peer_addr().ok(); - Ok((io, peer_addr)) + ready(Ok((io, peer_addr))) }) .and_then(self) } @@ -136,9 +137,9 @@ mod openssl { .map_err(TlsError::Tls) .map_init_err(|_| panic!()), ) - .and_then(|io: TlsStream| async { + .and_then(|io: TlsStream| { let peer_addr = io.get_ref().peer_addr().ok(); - Ok((io, peer_addr)) + ready(Ok((io, peer_addr))) }) .and_then(self.map_err(TlsError::Service)) } @@ -194,9 +195,9 @@ mod rustls { .map_err(TlsError::Tls) .map_init_err(|_| panic!()), ) - .and_then(|io: TlsStream| async { + .and_then(|io: TlsStream| { let peer_addr = io.get_ref().0.peer_addr().ok(); - Ok((io, peer_addr)) + ready(Ok((io, peer_addr))) }) .and_then(self.map_err(TlsError::Service)) }