Closed
Description
I'm trying to run a hyper server, but after closing the guard, I can't drop it and it hangs. Here's some example code where it happens (sorry for the muda, was trying a ton of things)
fn request_temp_code() -> TempCode {
Command::new("xdg-open").arg(format!("https://slack.com/oauth/authorize?client_id={}", SLACK_CLIENT_ID)).output().unwrap();
let server = Server::http(Ipv4Addr(127, 0, 0, 1), 9999);
let (tx, rx) = channel();
let mtx = Mutex::new(tx);
let mut guard = server.listen(move |req: Request, res: Response| {
match req.uri {
AbsolutePath(path) => {
// Trying to manually drop to see if this is the problem
let tempcode = extract_temp_code(&path).unwrap();
let gmtx = mtx.lock().unwrap();
gmtx.send(tempcode).unwrap();
drop(gmtx);
},
_ => ()
}
let mut res = res.start().unwrap();
res.write_all(b"Thanks! Please return to Lax").unwrap();
res.end().unwrap();
}).unwrap();
let tempcode = rx.recv().unwrap();
guard.close().unwrap();
println!("{}", "Auth code received!");
println!("{}", "Server closed!");
// Hangs here
tempcode
}
I haven't tried this with earlier versions of hyper (I think, not tracking numbers), however one of the last commits did involve changes related to the thread spawning into the acceptor. Have I found a possible bug?