Skip to content

Commit 20c2da1

Browse files
fakeshadowrobjtede
andauthored
Fix worker_avail (#336)
Co-authored-by: Rob Ede <[email protected]>
1 parent fdafc1d commit 20c2da1

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

actix-server/src/accept.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,11 @@ impl Availability {
116116
panic!("Max WorkerHandle count is 512")
117117
};
118118

119+
let off = 1 << idx as u128;
119120
if avail {
120-
self.0[offset] |= 1 << idx as u128;
121+
self.0[offset] |= off;
121122
} else {
122-
let shift = 1 << idx as u128;
123-
124-
debug_assert_ne!(self.0[offset] & shift, 0);
125-
126-
self.0[offset] ^= shift;
123+
self.0[offset] &= !off
127124
}
128125
}
129126

@@ -527,6 +524,9 @@ mod test {
527524

528525
aval.set_available(idx, false);
529526
assert!(!aval.available());
527+
528+
aval.set_available(idx, false);
529+
assert!(!aval.available());
530530
}
531531

532532
fn multi(aval: &mut Availability, mut idx: Vec<usize>) {
@@ -565,13 +565,6 @@ mod test {
565565
single(&mut aval, 512);
566566
}
567567

568-
#[test]
569-
#[should_panic]
570-
fn double_set_unavailable() {
571-
let mut aval = Availability::default();
572-
aval.set_available(233, false);
573-
}
574-
575568
#[test]
576569
fn pin_point() {
577570
let mut aval = Availability::default();

0 commit comments

Comments
 (0)