Skip to content

Commit

Permalink
Merge pull request #386 from hsiangkao/http_waker
Browse files Browse the repository at this point in the history
http: fix waker dead improperly due to lifetime mismatch
  • Loading branch information
imeoer authored Apr 14, 2022
2 parents d73e271 + 9f62a71 commit da861d4
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 da861d4

Please sign in to comment.