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

ReadWriteLock upgradeToWrite fix for simultaneous upgrades. #134

Merged
merged 1 commit into from
Nov 8, 2020

Conversation

accelerated
Copy link
Contributor

Description

If ReadWriteLock::upgradeToWrite() was called and there were more than one simultaneous upgrades occurring, the function would block indefinitely. This was caused by the underlying loop calling tryUpgradeToLock() not keeping upgrade state during iterations.
This fix introduces a new overload ReadWriteSpinlock::tryUpgradeToWrite(bool& pendingUpgrade) which should be used if calling this in a loop.

Testing performed
The previous tests only covered calling ReadWriteSpinlock::upgradeToWrite() which worked properly because it was not invoked inside a loop. The ReadWriteMutex::upgradeToWrite() calls it in a loop which was never actually tested. As a validation, running the new added test on the previous master branch blocks indefinitely which proves the fix is working correctly.

Signed-off-by: Alexander Damian adamian@bloomberg.net

Signed-off-by: Alexander Damian <adamian@bloomberg.net>
Copy link
Contributor

@arosenzweig3 arosenzweig3 left a comment

Choose a reason for hiding this comment

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

Looks good.

@accelerated accelerated merged commit eff98e7 into bloomberg:master Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants