From 20c2da17ed9679d7719d605ce5bc029c4a6fd713 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Thu, 15 Apr 2021 19:20:02 -0700 Subject: [PATCH] Fix worker_avail (#336) Co-authored-by: Rob Ede --- actix-server/src/accept.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/actix-server/src/accept.rs b/actix-server/src/accept.rs index 026bcc37..5b152fb2 100644 --- a/actix-server/src/accept.rs +++ b/actix-server/src/accept.rs @@ -116,14 +116,11 @@ impl Availability { panic!("Max WorkerHandle count is 512") }; + let off = 1 << idx as u128; if avail { - self.0[offset] |= 1 << idx as u128; + self.0[offset] |= off; } else { - let shift = 1 << idx as u128; - - debug_assert_ne!(self.0[offset] & shift, 0); - - self.0[offset] ^= shift; + self.0[offset] &= !off } } @@ -527,6 +524,9 @@ mod test { aval.set_available(idx, false); assert!(!aval.available()); + + aval.set_available(idx, false); + assert!(!aval.available()); } fn multi(aval: &mut Availability, mut idx: Vec) { @@ -565,13 +565,6 @@ mod test { single(&mut aval, 512); } - #[test] - #[should_panic] - fn double_set_unavailable() { - let mut aval = Availability::default(); - aval.set_available(233, false); - } - #[test] fn pin_point() { let mut aval = Availability::default();