Skip to content

Commit

Permalink
http: fix waker dead improperly due to lifetime mismatch
Browse files Browse the repository at this point in the history
The mio waker must be alive to get the notification delivered,
otherwise the inflight notification may get dropped silently.

Signed-off-by: Liu Jiang <[email protected]>
Signed-off-by: Gao Xiang <[email protected]>
  • Loading branch information
hsiangkao committed Apr 14, 2022
1 parent d73e271 commit 9f62a71
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(())
})?;

Expand Down

0 comments on commit 9f62a71

Please sign in to comment.