Skip to content

Only one connection being handled at a time #115

Description

@gmbeard

I believe that the placement of the call to pool.scoped inside the loop 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 the scoped_threadpool documentation suggests that the entire loop be enclosed in the Pool::scoped closure.

simple-server/src/lib.rs

Lines 254 to 269 in 10103f5

loop {
// Incoming is an endless iterator, so it's okay to unwrap on it.
let stream = incoming.next().unwrap();
let stream = stream.expect("Error handling TCP stream.");
stream
.set_read_timeout(Some(Duration::from_millis(READ_TIMEOUT_MS)))
.expect("FATAL: Couldn't set read timeout on socket");
pool.scoped(|scope| {
scope.execute(|| {
self.handle_connection(stream)
.expect("Error handling connection.");
});
});
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions