aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.bleep2
-rw-r--r--pingora-core/src/apps/mod.rs13
2 files changed, 12 insertions, 3 deletions
diff --git a/.bleep b/.bleep
index 26298b0..0c316c3 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-78684dca2f7fe5d952d3b01faec526a1b1cbad8c \ No newline at end of file
+a4032182c556d6fee5f22d0b56b99b03c8fc6868 \ No newline at end of file
diff --git a/pingora-core/src/apps/mod.rs b/pingora-core/src/apps/mod.rs
index 0786d08..2a77a3d 100644
--- a/pingora-core/src/apps/mod.rs
+++ b/pingora-core/src/apps/mod.rs
@@ -20,6 +20,7 @@ pub mod prometheus_http_app;
use crate::server::ShutdownWatch;
use async_trait::async_trait;
use log::{debug, error};
+use std::future::poll_fn;
use std::sync::Arc;
use crate::protocols::http::v2::server;
@@ -148,11 +149,19 @@ where
Ok(c) => c,
};
+ let mut shutdown = shutdown.clone();
loop {
// this loop ends when the client decides to close the h2 conn
// TODO: add a timeout?
- let h2_stream =
- server::HttpSession::from_h2_conn(&mut h2_conn, digest.clone()).await;
+ let h2_stream = tokio::select! {
+ _ = shutdown.changed() => {
+ h2_conn.graceful_shutdown();
+ let _ = poll_fn(|cx| h2_conn.poll_closed(cx))
+ .await.map_err(|e| error!("H2 error waiting for shutdown {e}"));
+ return None;
+ }
+ h2_stream = server::HttpSession::from_h2_conn(&mut h2_conn, digest.clone()) => h2_stream
+ };
let h2_stream = match h2_stream {
Err(e) => {
// It is common for the client to just disconnect TCP without properly