mirror of
https://github.com/DNSCrypt/encrypted-dns-server.git
synced 2024-05-07 12:46:05 +02:00
Handle accept() that can fail for Prometheus, too
This commit is contained in:
parent
2aa378cae4
commit
9ddeadc2ba
|
@ -55,7 +55,16 @@ pub async fn prometheus_service(
|
|||
let stream = TcpListener::bind(metrics_config.listen_addr).await?;
|
||||
let concurrent_connections = Arc::new(AtomicU32::new(0));
|
||||
loop {
|
||||
let (client, _client_addr) = stream.accept().await?;
|
||||
let (client, _client_addr) = match stream.accept().await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
if e.kind() == std::io::ErrorKind::WouldBlock {
|
||||
continue;
|
||||
}
|
||||
warn!("Error accepting Prometheus connection: {}", e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let count = concurrent_connections.fetch_add(1, Ordering::Relaxed);
|
||||
if count >= METRICS_MAX_CONCURRENT_CONNECTIONS {
|
||||
concurrent_connections.fetch_sub(1, Ordering::Relaxed);
|
||||
|
|
Loading…
Reference in New Issue