proxy: log if there are too many open connections
This commit is contained in:
parent
0081903f7c
commit
ea93bea7bf
@ -167,12 +167,12 @@ fn accept_connections(
|
|||||||
debug: bool,
|
debug: bool,
|
||||||
) -> tokio::sync::mpsc::Receiver<Result<tokio_openssl::SslStream<tokio::net::TcpStream>, Error>> {
|
) -> tokio::sync::mpsc::Receiver<Result<tokio_openssl::SslStream<tokio::net::TcpStream>, Error>> {
|
||||||
|
|
||||||
let (sender, receiver) = tokio::sync::mpsc::channel(1024);
|
const MAX_PENDING_ACCEPTS: usize = 1024;
|
||||||
|
|
||||||
|
let (sender, receiver) = tokio::sync::mpsc::channel(MAX_PENDING_ACCEPTS);
|
||||||
|
|
||||||
let accept_counter = Arc::new(());
|
let accept_counter = Arc::new(());
|
||||||
|
|
||||||
const MAX_PENDING_ACCEPTS: usize = 1024;
|
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
match listener.accept().await {
|
match listener.accept().await {
|
||||||
@ -186,9 +186,7 @@ fn accept_connections(
|
|||||||
let mut sender = sender.clone();
|
let mut sender = sender.clone();
|
||||||
|
|
||||||
if Arc::strong_count(&accept_counter) > MAX_PENDING_ACCEPTS {
|
if Arc::strong_count(&accept_counter) > MAX_PENDING_ACCEPTS {
|
||||||
if debug {
|
|
||||||
eprintln!("connection rejected - to many open connections");
|
eprintln!("connection rejected - to many open connections");
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user