Skip to content

Commit f21eaa9

Browse files
authored
Reduce size of Conn by removing unused addr field (#304)
1 parent 8becb0d commit f21eaa9

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

actix-server/src/accept.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,10 @@ impl Accept {
391391
.expect("ServerSocketInfo is removed from Slab");
392392

393393
match info.lst.accept() {
394-
Ok((io, addr)) => {
394+
Ok(io) => {
395395
let msg = Conn {
396396
io,
397397
token: info.token,
398-
peer: Some(addr),
399398
};
400399
self.accept_one(sockets, msg);
401400
}

actix-server/src/socket.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,11 @@ impl MioListener {
4040
}
4141
}
4242

43-
pub(crate) fn accept(&self) -> io::Result<(MioStream, SocketAddr)> {
43+
pub(crate) fn accept(&self) -> io::Result<MioStream> {
4444
match *self {
45-
MioListener::Tcp(ref lst) => lst
46-
.accept()
47-
.map(|(stream, addr)| (MioStream::Tcp(stream), SocketAddr::Tcp(addr))),
45+
MioListener::Tcp(ref lst) => lst.accept().map(|(stream, _)| MioStream::Tcp(stream)),
4846
#[cfg(unix)]
49-
MioListener::Uds(ref lst) => lst
50-
.accept()
51-
.map(|(stream, addr)| (MioStream::Uds(stream), SocketAddr::Uds(addr))),
47+
MioListener::Uds(ref lst) => lst.accept().map(|(stream, _)| MioStream::Uds(stream)),
5248
}
5349
}
5450
}

actix-server/src/worker.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
1414
use tokio::sync::oneshot;
1515

1616
use crate::service::{BoxedServerService, InternalServiceFactory};
17-
use crate::socket::{MioStream, SocketAddr};
17+
use crate::socket::MioStream;
1818
use crate::waker_queue::{WakerInterest, WakerQueue};
1919
use crate::{join_all, Token};
2020

@@ -31,7 +31,6 @@ pub(crate) struct StopCommand {
3131
pub(crate) struct Conn {
3232
pub io: MioStream,
3333
pub token: Token,
34-
pub peer: Option<SocketAddr>,
3534
}
3635

3736
static MAX_CONNS: AtomicUsize = AtomicUsize::new(25600);

0 commit comments

Comments
 (0)