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

Don't take the tail lock when dropping broadcast channel's Recv future #6298

Merged
merged 9 commits into from
Jan 27, 2024
Prev Previous commit
Next Next commit
Use load/store instead of get_mut
vnetserg committed Jan 27, 2024
commit be6b4bc12ee25f9b8c85acf35784fde727782765
8 changes: 6 additions & 2 deletions tokio/src/sync/broadcast.rs
Original file line number Diff line number Diff line change
@@ -1112,8 +1112,12 @@ impl<T> Receiver<T> {
}

// If the waiter is not already queued, enqueue it.
if !*(*ptr).queued.get_mut() {
*(*ptr).queued.get_mut() = true;
// `Relaxed` order suffices: we have synchronized with
// all writers through the tail lock that we hold.
if (*ptr).queued.load(Relaxed) {
// `Relaxed` order suffices: all the readers will
// synchronize with this write through the tail lock.
(*ptr).queued.store(true, Relaxed);
tail.waiters.push_front(NonNull::new_unchecked(&mut *ptr));
}
});