Set keepalive and tcp_nodelay on underlying sockets

This commit is contained in:
jiangjianfeng
2024-12-05 08:40:20 +00:00
committed by Tate, Hongliang Tian
parent 8b07a68e9e
commit 58cf8ea681
13 changed files with 293 additions and 35 deletions

View File

@ -1,6 +1,9 @@
// SPDX-License-Identifier: MPL-2.0
use aster_bigtcp::{socket::UnboundTcpSocket, wire::IpEndpoint};
use aster_bigtcp::{
socket::{RawTcpSetOption, UnboundTcpSocket},
wire::IpEndpoint,
};
use super::{connecting::ConnectingStream, listen::ListenStream, StreamObserver};
use crate::{
@ -108,4 +111,14 @@ impl InitStream {
// Linux adds OUT and HUP events for a newly created socket
IoEvents::OUT | IoEvents::HUP
}
pub(super) fn set_raw_option<R>(
&mut self,
set_option: impl Fn(&mut dyn RawTcpSetOption) -> R,
) -> R {
match self {
InitStream::Unbound(unbound_socket) => set_option(unbound_socket.as_mut()),
InitStream::Bound(bound_socket) => set_option(bound_socket),
}
}
}