Compare commits

..

No commits in common. "182b2af7e5188e84543cf80d60d667cb0d87fe88" and "3dda1ee4f6ab85d668aaf810667e611832fccc0c" have entirely different histories.

View file

@ -2,7 +2,6 @@ use std::convert::Infallible;
use std::fs::{self, Permissions}; use std::fs::{self, Permissions};
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait; use async_trait::async_trait;
@ -20,7 +19,6 @@ use hyper_util::rt::TokioIo;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::{TcpListener, TcpStream, UnixListener, UnixStream}; use tokio::net::{TcpListener, TcpStream, UnixListener, UnixStream};
use tokio::sync::watch; use tokio::sync::watch;
use tokio::time::{sleep_until, Instant};
use opentelemetry::{ use opentelemetry::{
global, global,
@ -293,7 +291,7 @@ where
let connection_collector = tokio::spawn({ let connection_collector = tokio::spawn({
let server_name = server_name.clone(); let server_name = server_name.clone();
async move { async move {
let mut connections = FuturesUnordered::<tokio::task::JoinHandle<()>>::new(); let mut connections = FuturesUnordered::new();
loop { loop {
let collect_next = async { let collect_next = async {
if connections.is_empty() { if connections.is_empty() {
@ -314,34 +312,23 @@ where
} }
} }
} }
let deadline = Instant::now() + Duration::from_secs(10); if !connections.is_empty() {
while !connections.is_empty() {
info!( info!(
"{} server: {} connections still open, deadline in {:.2}s", "{} server: {} connections still open",
server_name, server_name,
connections.len(), connections.len()
(deadline - Instant::now()).as_secs_f32(),
); );
tokio::select! { while let Some(conn_res) = connections.next().await {
conn_res = connections.next() => {
trace!( trace!(
"{} server: HTTP connection finished: {:?}", "{} server: HTTP connection finished: {:?}",
server_name, server_name,
conn_res.unwrap(), conn_res
); );
} info!(
_ = sleep_until(deadline) => { "{} server: {} connections still open",
warn!("{} server: exit deadline reached with {} connections still open, killing them now",
server_name, server_name,
connections.len()); connections.len()
for conn in connections.iter() { );
conn.abort();
}
for conn in connections {
assert!(conn.await.unwrap_err().is_cancelled());
}
break;
}
} }
} }
} }