This commit is contained in:
Jun Kurihara 2022-07-07 13:45:26 +09:00
commit 8bebdc82ab
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
2 changed files with 18 additions and 15 deletions

View file

@ -9,7 +9,23 @@ impl<T> Proxy<T>
where
T: Connect + Clone + Sync + Send + 'static,
{
pub async fn client_serve_h3(self, conn: quinn::Connecting) -> Result<()> {
pub async fn client_serve_h3(self, conn: quinn::Connecting) {
let clients_count = self.globals.clients_count.clone();
if clients_count.increment() > self.globals.max_clients {
clients_count.decrement();
return;
}
let fut = self.clone().handle_connection_h3(conn);
self.globals.runtime_handle.spawn(async move {
if let Err(e) = fut.await {
warn!("QUIC or HTTP/3 connection failed: {}", e)
}
clients_count.decrement();
debug!("Client #: {}", clients_count.current());
});
}
pub async fn handle_connection_h3(self, conn: quinn::Connecting) -> Result<()> {
let client_addr = conn.remote_address();
match conn.await {

View file

@ -147,20 +147,7 @@ where
let peekable_incoming = std::pin::Pin::new(&mut p);
if let Some(conn) = peekable_incoming.get_mut().next().await {
if success {
// TODO: client数の管理
let clients_count = self.globals.clients_count.clone();
if clients_count.increment() > self.globals.max_clients {
clients_count.decrement();
continue;
}
let fut = self.clone().client_serve_h3(conn);
self.globals.runtime_handle.spawn(async move {
if let Err(e) = fut.await {
warn!("QUIC or HTTP/3 connection failed: {}", e)
}
clients_count.decrement();
debug!("Client #: {}", clients_count.current());
});
self.clone().client_serve_h3(conn).await;
}
} else {
break;