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 inherit Send from parking_lot::*Guard #4359

merged 6 commits into from
Dec 31, 2021


Copy link

Currently our tokio::sync::watch::Ref type can become Send if Tokio is compiled with the parking_lot feature and parking_lot is compiled with its send_guard feature. This PR will prevent the send_guard feature from affecting whether Tokio types are Send or not.

Strictly speaking, this PR is a breaking change, however I believe we should make the change regardless. As it stands now, the parking_lot crate is in our public API, and if don't want to make this change, then we should also commit to never upgrading parking_lot beyond 0.11.x, as such an upgrade would be also be a breaking change for the same reasons.

I don't think many people will be affected by this. Anyone who is affected is probably holding a tokio::sync::watch::Ref alive across an .await, which is always incorrect.

The first commit in this PR adds a test to CI that should catch this in the future. The commit is first so we can see the test fail without the change. The test relies on tokio/tokio/tests/

@Darksonn Darksonn added the A-tokio Area: The main tokio crate label Dec 30, 2021
Copy link

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like the best solution to me. I left some minor nitpicks but didn't see any blockers.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
Comment on lines 15 to 18
pub(crate) struct Mutex<T: ?Sized>(PhantomData<std::sync::Mutex<T>>, parking_lot::Mutex<T>);

pub(crate) struct RwLock<T>(parking_lot::RwLock<T>);
pub(crate) struct RwLock<T>(PhantomData<std::sync::RwLock<T>>, parking_lot::RwLock<T>);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have a slight preference for either making these named fields, or breaking them across multiple lines like we do with the guard types...this feels like a lot for one line. not a blocker though.

tokio/src/loom/std/ Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
A-tokio Area: The main tokio crate
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants