-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix Weak Increment Race Condition #60
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump the MSRV to 1.45, since fetch_update
wasn't stable until then.
Also run cargo fmt --all
to keep the code looking nice.
@notgull CI is passing now, except the MSRV check is failing, seemingly due a flaky failure to download the Cargo registry. Could you please rerun that action? I don't have permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me aside from a minor ordering change.
} else { | ||
Some(Sender { | ||
match self.channel.sender_count.fetch_update( | ||
Ordering::Relaxed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The set ordering here should be Release
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on what this would guard against? I'm not seeing any other writes that this would need to be ordered with, but I'm probably just missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The sender/receiver counts are currently read and updated separately, which means there's a possible race condition where two attempt to get upgraded from different threads at the same time. This PR switches to using
fetch_update
to avoid this issue