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

Remove atomic enum election::state_m and instead require locking election::mutex. #4318

Merged
merged 9 commits into from
Jan 16, 2024

Conversation

clemahieu
Copy link
Contributor

No description provided.

@clemahieu clemahieu force-pushed the election_state_mutex branch 5 times, most recently from 298b348 to e174edf Compare November 7, 2023 12:41
@dsiganos
Copy link
Contributor

dsiganos commented Jan 10, 2024

@clemahieu, could you explain why this change is needed, what problem does it solve.

@clemahieu
Copy link
Contributor Author

This change is removing the atomic election::state_m variable in favor of using the election mutex for synchronization. The issue is there are two synchronization mechanisms in use, locking the mutex or doing an atomic compare exchange, which has race conditions.

From what I recall the election can be doing an operation with a locked mutex, and a separate action can change the election state because it doesn't respect the mutex being locked.

@clemahieu
Copy link
Contributor Author

LGTM

@clemahieu clemahieu merged commit 978020e into nanocurrency:develop Jan 16, 2024
18 of 19 checks passed
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.

3 participants