aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-24 20:06:31 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-24 20:06:31 +0100
commit7d5070c57dabfb22c5bd17a850adcbbfa19d730a (patch)
tree356afc8c9ae507d15cc1a19311511cb4554518ad
parent10d13b194bca5bb67db734a904eaa6fe1da6087f (diff)
downloadtricot-7d5070c57dabfb22c5bd17a850adcbbfa19d730a.tar.gz
tricot-7d5070c57dabfb22c5bd17a850adcbbfa19d730a.zip
Fix busy loopdocker-32
-rw-r--r--src/https.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/https.rs b/src/https.rs
index 7aa61d5..d621cfe 100644
--- a/src/https.rs
+++ b/src/https.rs
@@ -56,9 +56,16 @@ pub async fn serve_https(
let mut connections = FuturesUnordered::new();
while !*must_exit.borrow() {
+ let wait_conn_finished = async {
+ if connections.is_empty() {
+ futures::future::pending().await
+ } else {
+ connections.next().await
+ }
+ };
let (socket, remote_addr) = select! {
a = tcp.accept() => a?,
- _ = connections.next() => continue,
+ _ = wait_conn_finished => continue,
_ = must_exit.changed() => continue,
};
@@ -105,9 +112,7 @@ pub async fn serve_https(
drop(tcp);
info!("HTTPS server shutting down, draining remaining connections...");
- while !connections.is_empty() {
- let _ = connections.next().await;
- }
+ while connections.next().await.is_some() {}
Ok(())
}