refactor
This commit is contained in:
parent
c027f4456d
commit
8bebdc82ab
2 changed files with 18 additions and 15 deletions
|
|
@ -9,7 +9,23 @@ impl<T> Proxy<T>
|
||||||
where
|
where
|
||||||
T: Connect + Clone + Sync + Send + 'static,
|
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();
|
let client_addr = conn.remote_address();
|
||||||
|
|
||||||
match conn.await {
|
match conn.await {
|
||||||
|
|
|
||||||
|
|
@ -147,20 +147,7 @@ where
|
||||||
let peekable_incoming = std::pin::Pin::new(&mut p);
|
let peekable_incoming = std::pin::Pin::new(&mut p);
|
||||||
if let Some(conn) = peekable_incoming.get_mut().next().await {
|
if let Some(conn) = peekable_incoming.get_mut().next().await {
|
||||||
if success {
|
if success {
|
||||||
// TODO: client数の管理
|
self.clone().client_serve_h3(conn).await;
|
||||||
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());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue