mirror of https://github.com/fafhrd91/actix-net
close channel early on drop of ServerWorker
This commit is contained in:
parent
39fc6569a7
commit
76d3e8ee75
|
@ -135,6 +135,13 @@ pub(crate) struct ServerWorker {
|
||||||
shutdown_timeout: Duration,
|
shutdown_timeout: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set worker to unavailable when dropping.
|
||||||
|
impl Drop for ServerWorker {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.rx.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct WorkerService {
|
struct WorkerService {
|
||||||
factory: usize,
|
factory: usize,
|
||||||
status: WorkerServiceStatus,
|
status: WorkerServiceStatus,
|
||||||
|
|
|
@ -517,6 +517,8 @@ async fn worker_restart() {
|
||||||
|
|
||||||
let (server, sys) = rx.recv().unwrap();
|
let (server, sys) = rx.recv().unwrap();
|
||||||
|
|
||||||
|
sleep(Duration::from_secs(3)).await;
|
||||||
|
|
||||||
let mut buf = [0; 8];
|
let mut buf = [0; 8];
|
||||||
|
|
||||||
// worker 1 would not restart and return it's id consistently.
|
// worker 1 would not restart and return it's id consistently.
|
||||||
|
@ -545,7 +547,6 @@ async fn worker_restart() {
|
||||||
|
|
||||||
// worker 2 restarting and work goes to worker 1.
|
// worker 2 restarting and work goes to worker 1.
|
||||||
let mut stream = TcpStream::connect(addr).await.unwrap();
|
let mut stream = TcpStream::connect(addr).await.unwrap();
|
||||||
|
|
||||||
let n = stream.read(&mut buf).await.unwrap();
|
let n = stream.read(&mut buf).await.unwrap();
|
||||||
let id = String::from_utf8_lossy(&buf[0..n]);
|
let id = String::from_utf8_lossy(&buf[0..n]);
|
||||||
assert_eq!("1", id);
|
assert_eq!("1", id);
|
||||||
|
|
Loading…
Reference in New Issue