From f21eaa954fe756f22ae0b9483281f27a5aacf179 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Wed, 31 Mar 2021 22:55:33 -0700 Subject: [PATCH] Reduce size of Conn by removing unused addr field (#304) --- actix-server/src/accept.rs | 3 +-- actix-server/src/socket.rs | 10 +++------- actix-server/src/worker.rs | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/actix-server/src/accept.rs b/actix-server/src/accept.rs index f5484434..2b9c7206 100644 --- a/actix-server/src/accept.rs +++ b/actix-server/src/accept.rs @@ -391,11 +391,10 @@ impl Accept { .expect("ServerSocketInfo is removed from Slab"); match info.lst.accept() { - Ok((io, addr)) => { + Ok(io) => { let msg = Conn { io, token: info.token, - peer: Some(addr), }; self.accept_one(sockets, msg); } diff --git a/actix-server/src/socket.rs b/actix-server/src/socket.rs index baf02cbe..0625cfda 100644 --- a/actix-server/src/socket.rs +++ b/actix-server/src/socket.rs @@ -40,15 +40,11 @@ impl MioListener { } } - pub(crate) fn accept(&self) -> io::Result<(MioStream, SocketAddr)> { + pub(crate) fn accept(&self) -> io::Result { match *self { - MioListener::Tcp(ref lst) => lst - .accept() - .map(|(stream, addr)| (MioStream::Tcp(stream), SocketAddr::Tcp(addr))), + MioListener::Tcp(ref lst) => lst.accept().map(|(stream, _)| MioStream::Tcp(stream)), #[cfg(unix)] - MioListener::Uds(ref lst) => lst - .accept() - .map(|(stream, addr)| (MioStream::Uds(stream), SocketAddr::Uds(addr))), + MioListener::Uds(ref lst) => lst.accept().map(|(stream, _)| MioStream::Uds(stream)), } } } diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index aa6d31fc..63c45757 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -14,7 +14,7 @@ use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; use tokio::sync::oneshot; use crate::service::{BoxedServerService, InternalServiceFactory}; -use crate::socket::{MioStream, SocketAddr}; +use crate::socket::MioStream; use crate::waker_queue::{WakerInterest, WakerQueue}; use crate::{join_all, Token}; @@ -31,7 +31,6 @@ pub(crate) struct StopCommand { pub(crate) struct Conn { pub io: MioStream, pub token: Token, - pub peer: Option, } static MAX_CONNS: AtomicUsize = AtomicUsize::new(25600);