From 9f62a71eee5bdede1d2669d831ab39226d0e15c7 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 14 Apr 2022 02:37:15 +0000 Subject: [PATCH] http: fix waker dead improperly due to lifetime mismatch The mio waker must be alive to get the notification delivered, otherwise the inflight notification may get dropped silently. Signed-off-by: Liu Jiang Signed-off-by: Gao Xiang --- api/src/http.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/http.rs b/api/src/http.rs index 217e316e14d..eefa7626ea8 100644 --- a/api/src/http.rs +++ b/api/src/http.rs @@ -399,8 +399,8 @@ pub fn start_http_thread( let socket_path = PathBuf::from(path); let mut pool = Poll::new()?; - let waker = Waker::new(pool.registry(), EXIT_TOKEN)?; - let waker = Arc::new(waker); + let waker = Arc::new(Waker::new(pool.registry(), EXIT_TOKEN)?); + let waker2 = waker.clone(); let mut server = HttpServer::new(socket_path).map_err(|e| { if let ServerError::IOError(e) = e { e @@ -463,8 +463,9 @@ pub fn start_http_thread( } } } - info!("http-server thread exits"); + // Keep the Waker alive to match the lifetime of the poll loop above + drop(waker2); Ok(()) })?;