1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 18:02:58 +01:00

Reduce size of Conn by removing unused addr field (#304)

This commit is contained in:
fakeshadow 2021-03-31 22:55:33 -07:00 committed by GitHub
parent 8becb0db70
commit f21eaa954f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View File

@ -391,11 +391,10 @@ impl Accept {
.expect("ServerSocketInfo is removed from Slab"); .expect("ServerSocketInfo is removed from Slab");
match info.lst.accept() { match info.lst.accept() {
Ok((io, addr)) => { Ok(io) => {
let msg = Conn { let msg = Conn {
io, io,
token: info.token, token: info.token,
peer: Some(addr),
}; };
self.accept_one(sockets, msg); self.accept_one(sockets, msg);
} }

View File

@ -40,15 +40,11 @@ impl MioListener {
} }
} }
pub(crate) fn accept(&self) -> io::Result<(MioStream, SocketAddr)> { pub(crate) fn accept(&self) -> io::Result<MioStream> {
match *self { match *self {
MioListener::Tcp(ref lst) => lst MioListener::Tcp(ref lst) => lst.accept().map(|(stream, _)| MioStream::Tcp(stream)),
.accept()
.map(|(stream, addr)| (MioStream::Tcp(stream), SocketAddr::Tcp(addr))),
#[cfg(unix)] #[cfg(unix)]
MioListener::Uds(ref lst) => lst MioListener::Uds(ref lst) => lst.accept().map(|(stream, _)| MioStream::Uds(stream)),
.accept()
.map(|(stream, addr)| (MioStream::Uds(stream), SocketAddr::Uds(addr))),
} }
} }
} }

View File

@ -14,7 +14,7 @@ use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
use tokio::sync::oneshot; use tokio::sync::oneshot;
use crate::service::{BoxedServerService, InternalServiceFactory}; use crate::service::{BoxedServerService, InternalServiceFactory};
use crate::socket::{MioStream, SocketAddr}; use crate::socket::MioStream;
use crate::waker_queue::{WakerInterest, WakerQueue}; use crate::waker_queue::{WakerInterest, WakerQueue};
use crate::{join_all, Token}; use crate::{join_all, Token};
@ -31,7 +31,6 @@ pub(crate) struct StopCommand {
pub(crate) struct Conn { pub(crate) struct Conn {
pub io: MioStream, pub io: MioStream,
pub token: Token, pub token: Token,
pub peer: Option<SocketAddr>,
} }
static MAX_CONNS: AtomicUsize = AtomicUsize::new(25600); static MAX_CONNS: AtomicUsize = AtomicUsize::new(25600);