-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only one connection being handled at a time #115
Comments
I think this should be an easy fix; Just rearrange the call to |
I can confirm this. I tested it with this server extern crate simple_server;
fn main() {
use simple_server::Server;
let server = Server::new(|request, mut response| {
if request.uri() == "/sleep" {
std::thread::sleep(std::time::Duration::from_secs(5));
Ok(response.body(b"Yawn\n".to_vec())?)
} else {
Ok(response.body(b"I'm ready!\n".to_vec())?)
}
});
server.listen("127.0.0.1", "7878");
} If the server uses one thread, if you request This also seems to fix the bug where if the handler panics the whole server goes down 👍 |
I have tested the following, and can confirm it works:
this also prevents a handler panic from bringing a thread down. (otherwise, it might seem like it continues to work, but I think you have still killed one of the threads in the thread pool) |
I believe that the placement of the call to
pool.scoped
inside theloop
statement isn't taking advantage of the thread pool. As it stands, I think only one connection at a time is being processed. The example in thescoped_threadpool
documentation suggests that the entire loop be enclosed in thePool::scoped
closure.simple-server/src/lib.rs
Lines 254 to 269 in 10103f5
The text was updated successfully, but these errors were encountered: