From 6c18af80f0dc469ff4f0ca25961817c7031acf50 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Thu, 15 Apr 2021 21:07:59 +0800 Subject: [PATCH] Add note for field order of ServerWorker --- actix-server/src/worker.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index cb99c99d..90f057d2 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -125,6 +125,8 @@ impl WorkerAvailability { /// /// Worker accepts Socket objects via unbounded channel and starts stream processing. pub(crate) struct ServerWorker { + // UnboundedReceiver should always the first field. + // It must be dropped as soon as ServerWorker dropping. rx: UnboundedReceiver, rx2: UnboundedReceiver, services: Box<[WorkerService]>, @@ -370,9 +372,7 @@ impl Default for WorkerState { impl Drop for ServerWorker { fn drop(&mut self) { - /// Close channel on drop. - self.rx.close(); - /// Stop Arbiter Self runs on on drop. + // Stop Arbiter Self runs on on drop. Arbiter::current().stop(); } }