Quickfix: Clear pool if stuck for too long
This commit is contained in:
parent
a9f605cf0e
commit
85e4cb3e4a
11
src/main.rs
11
src/main.rs
@ -6,6 +6,8 @@ use std::{
|
||||
net::{TcpListener, TcpStream},
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use data_stream::{
|
||||
@ -27,7 +29,7 @@ fn main() {
|
||||
};
|
||||
|
||||
let mut context = Context::default();
|
||||
let pool = ThreadPool::new(4);
|
||||
let mut pool = ThreadPool::new(4);
|
||||
|
||||
let mut args = env::args();
|
||||
args.next();
|
||||
@ -43,6 +45,13 @@ fn main() {
|
||||
continue;
|
||||
};
|
||||
|
||||
if pool.active_count() == pool.max_count() {
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
if pool.active_count() == pool.max_count() {
|
||||
pool = ThreadPool::new(pool.max_count())
|
||||
}
|
||||
}
|
||||
|
||||
context.handle_connection(&path, stream, &pool);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user