From 162ccef1e44efb292f3c9da618707afea1ea2851 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 25 Sep 2023 17:53:01 +0800 Subject: [PATCH] inbound/quic: make an option for QUIC inbound accept channel size --- leaf/src/option/mod.rs | 4 ++++ leaf/src/proxy/quic/inbound/datagram.rs | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/leaf/src/option/mod.rs b/leaf/src/option/mod.rs index b2623d2..967e3cd 100644 --- a/leaf/src/option/mod.rs +++ b/leaf/src/option/mod.rs @@ -132,6 +132,10 @@ lazy_static! { get_env_var_or("UDP_DOWNLINK_CHANNEL_SIZE", 256) }; + pub static ref QUIC_ACCEPT_CHANNEL_SIZE: usize = { + get_env_var_or("QUIC_ACCEPT_CHANNEL_SIZE", 1024) + }; + /// Buffer size for UDP datagrams receiving/sending, in KB. pub static ref DATAGRAM_BUFFER_SIZE: usize = { get_env_var_or("DATAGRAM_BUFFER_SIZE", 2) diff --git a/leaf/src/proxy/quic/inbound/datagram.rs b/leaf/src/proxy/quic/inbound/datagram.rs index 8c50e35..3779e9e 100644 --- a/leaf/src/proxy/quic/inbound/datagram.rs +++ b/leaf/src/proxy/quic/inbound/datagram.rs @@ -135,8 +135,7 @@ async fn handle_conn( #[async_trait] impl InboundDatagramHandler for Handler { async fn handle<'a>(&'a self, socket: AnyInboundDatagram) -> io::Result { - // FIXME What is a good size for this? - let (stream_tx, stream_rx) = channel(1024); + let (stream_tx, stream_rx) = channel(*crate::option::QUIC_ACCEPT_CHANNEL_SIZE); let endpoint = quinn::Endpoint::new( quinn::EndpointConfig::default(), Some(self.server_config.clone()),