Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and fix unsoundness and CI failure #29

Merged
merged 13 commits into from
Jun 19, 2022
Prev Previous commit
Next Next commit
Move drop(state) to fix UB
taiki-e committed Jun 17, 2022
commit 95aa5bf8b160ee245bcfd3d61c43cbda17663a72
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -195,16 +195,18 @@ impl<T: Clone + Sync> Seat<T> {
// safely take a mutable reference, and just take the val instead of cloning it.
unsafe { &mut *self.state.get() }.val.take().unwrap()
} else {
state
let v = state
.val
.clone()
.expect("seat that should be occupied was empty")
.expect("seat that should be occupied was empty");

// let writer know that we no longer need this item.
// state is no longer safe to access.
#[allow(clippy::drop_ref)]
drop(state);
v
};

// let writer know that we no longer need this item.
// state is no longer safe to access.
#[allow(clippy::drop_ref)]
drop(state);
self.read.fetch_add(1, atomic::Ordering::AcqRel);

if let Some(t) = waiting {